android - PHP Firebase Clood Messaging (FCM) error missing registration -
i building push notification server fcm server. getting following errors: error=missingregistration
my php code given below.
function send($id,$title,$text){ $msg = [ 'title' => $title, 'body' => $text, 'icon' => 'myicon', 'sound' => 'mysound' ]; $fields = [ 'to' => $id, 'notification' => $msg ]; $headers = [ 'authorization: key=' . $api_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_postfields, $fields ); $result = curl_exec ( $ch ); curl_close ( $ch ); echo $result; }
i calling function this:
send($id,$title,$text);
for sending data fcm need create json data. please add line after fields
$fields = json_encode($fields);
Comments
Post a Comment