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


I am trying to send a push notification through the Push API, as explained here:

But the response I’m getting is always this:
“result”: “error”,
“message”: “Either a single or list of tokens is required”

My payload is this:
“alert”:“Hello World!”,
“expiry”: 1423238641,
“priority”: 10,
“contentAvailable”: true,

I tried many variations: passing a single string instead of an array, passing real and fake tokens, passing dev and android tokens, passing just one token in the array, with out without the optional sections of “android” and “ios”.

I always get the error above.

Any ideas why?


I am having the same issue, and I am using a script that worked for me previously. Perhaps something has recently broken?


Hi, i’m using the Advanced Rest Client.

And works perfect to me


X-Ionic-Application-Id: YOUR_APP_ID


    "alert":"Hello World!",
      "expiry": 1423238641,
      "priority": 10,
      "contentAvailable": true,

test this, if you need i have a php script who works perfect to me.


Hi Obenavidez,

May i have the PHP script that you are using to push notification which works for you?

Best Regards,


sorry desBiz for the late this is my script

$link = Conectarse();

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

if ( !$resultado ) 
        exit( "Error en la consulta SQL" ); 

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

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


$url = '';

$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);



I had a similar problem when creating a request in C# using the RestSharp library.

This worked for me:

var privateKey = "xxxx"; var tokens = new String[] { "yyyy", "yyyy" }; var appId = "zzzz";
        dynamic jsonPostData = new
            tokens = tokens,
            production = false,
            notification = new
                alert = "Hello world",
                title = "test",

        var client = new RestClient("");
        client.Authenticator = new HttpBasicAuthenticator(privateKey, "");

        var request = new RestRequest("push", Method.POST);


        request.AddHeader("Content-Type", "application/json");
        request.AddHeader("X-Ionic-Application-Id", appId);

        var response = client.Execute(request);
        var content = response.Content;

The request has 5 parameters:

{application/json={“tokens”:[“yyyy”,“yyyy”],“production”:false,“notification”:{“alert”:“Hello world”,“title”:“test”}}}
{Authorization=Basic xxxx-encodedbase64}
{Accept=application/json, application/xml, text/json, text/x-json, text/javascript, text/xml}