Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Getting an error from Ionic Push API when trying to send a push notification

$
0
0

sorry desBiz for the late this is my script

<?php
include("../conexion/conexion.inc.php");
$link = Conectarse();
error_reporting(0);

$sql = "select token_push from mo_usuario where estado = '1'";

$resultado=mysql_query($sql);
                
if ( !$resultado ) 
    { 
        exit( "Error en la consulta SQL" ); 
    }

$data=array();
$i=0;
while($row=mysql_fetch_array($resultado, MYSQL_ASSOC)){    
$data[] = $row['token_push'];
}

$msg = "Nuevas Promociones y Eventos";//$_GET['msg'];
$user = "MoveOn";//$_GET['user'];

$device_token=$data;



$url = 'https://push.ionic.io/api/v1/push';

$data = array(
                  'tokens' => $device_token, 
                  'notification' => array('alert' => ''.$user.': '.$msg),      
                  );
echo json_encode($data);
$content = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_USERPWD, "public-key-of-your-app" . ":" );  
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-Ionic-Application-Id: your-id-ionic-app' 
));
$result = curl_exec($ch);
//var_dump($result);
curl_close($ch);

?>

Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>