I'm trying to send push notification on my android app but I always received the error :
"InvalidRegistration"
This is the tokens that I sent in the "to"
My code:-
public function android_push($token, $load, $key) {
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'registration_ids' => $token,
'data' => $load
);
$headers = array(
'Authorization: key=' . $key,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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, true));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
My params:
{"title":"Test","msg":"test"}
token: ["pid_58cc-6fed***"]
key:AA*****zEoEbsgPZCjK_umqrmgMZRkpyN7BAA5MNfGuojQP5olWIe1H_vzU8-9THNcB-CgZAjA6fwL72yE******6V7Cl-IObLDGwA6SqTopuK96begUtysy_cG8rc02vdIeYx****
result:
{"multicast_id":4723735099133341876,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}