0 Replies Latest reply on Dec 1, 2017 1:00 AM by neworld.designs

    Firebase error MismatchSenderId

    neworld.designs Level 1

      I am trying to send the notification using a php script that is stored in my server and I am getting the MismatchSenderId.

      $to="device_id"; 
      $title
      ="MYAPP Push";
      $message
      =" MYAPP Push Notification Message"; 
       
      function sendPush($to,$title,$message){
           // API access key from Google API's Console
           // replace API define( "API_ACCESS_KEY", "server_key_provided_by_firebase"); 
           $registrationIds
      = array($to); 
           $msg
      = array( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData );
       
           $fields
      = array( 'registration_ids' => $registrationIds, 'data' => $msg ); 
           $headers
      = array( 'Authorization: key=' . API_ACCESS_KEY, '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
      ;
      }

      sendPush($to,$title,$message);

      Here the error I get when I run the php script: {"multicast_id":7804476702639319453,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}

      I am using firebase (spark plan) and developing the app with Phonegap. I believe that has nothing to do with the app

      Any Ideas???