I am currently trying to make use of cloud messaging for my Android app. The server is sending messages via PHP using
The problem is that the server’s response is always:
I use the WebAPI Access key from the Firebase Console for my App, so this is definitively the right one. Below is the code I use to send the data:
<?php $fields = array( 'to' => "<MY-RECIPIENT-TOKEN>", 'notification' => array( 'body' => 'Test message :)', 'title' => 'Test', 'icon' => 'myicon', 'sound' => 'mySound' ) ); $headers = array( 'Authorization:key=<MY AUTH KEY IS HERE>', 'Content-Type:application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); curl_close($ch); echo $result;
MY-RECIPIENT-TOKEN is received from the App and the
MY AUTH KEY IS HERE is the key from the Firebase Console.
What am I missing here?