Arivan Bastos Arivan Bastos - 3 years ago 204
PHP Question

Google Firebase iOS push works in console but not in API

I'm using to receive Google Firebase messages on a ionic based app.

After set certificates, install plugin and setup Firebase account I was able to receive notifications (on both android and ios devices) sended through the Firebase Console.

But when I send through the Firebase API ( only android devices receive the notification. I'm using the following code:

$data = Array
[to] => <token>
[notification] => Array
[title] => My Title
[text] => Notification test
[sound] => default
[vibrate] => 1
[badge] => 0


$jsonData = json_encode($data);
$ch = curl_init("");
$header = array(
'Content-Type: application/json',
"Authorization: key=".$gcmApiKey

curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);

$result = curl_exec($ch);

echo $result;

No errors are returned:


What can be wrong?

Answer Source

For iOS, try adding in parameter priority set to high and content_available set to true in your payload.

See the parameter details here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download