0

J'essaie d'envoyer une notification push à mon Cordova Ios App.Envoyer une notification push avec FCM sur IOS

J'utilise le plugin cordova-plugin-fcm

Pour mon application Android, il est un travail tout à fait, le problème est Ios, mon retour à la demande boucle:

InvalidApnsCredential

Je télécharger mon APNS clé sur FCM et ce travail clé parce que j'ai essayé d'envoyer une notification push avec juste Apns et il fonctionne très bien mon application reçoit la notification.

Voici le script APNS qui travaillent: http://thrysoee.dk/apns/

Voici mon script php curl avec la FCM Wich travail avec Android, mais pas Ios:

$pushUrl = "FCM_PUSH_URL"; //https://fcm.googleapis.com/fcm/send 
    $key  = "SERVER_KEY";//Server key get in FCM console 
    $ch   = curl_init($pushUrl); 
    $headers = []; 

    $headers[] = 'Content-Type: application/json'; 
    $headers[] = 'Authorization:key=' . $key; 
    $data = array(
     "notification" => array(
      "title"   => "Bonjour le monde !", 
      "body"   => "Notif de test", 
      //"click_action" =>"FCM_PLUGIN_ACTIVITY", 
      "icon"   => "fcm_push_icon", 
     ), 
     "data" => array(
      'msg'  => 'hello', 
      'msg2' => 'world' 
     ), 
     "to"  => "MY_IOS_REGISTER_TOKEN"//token get on my ipad with the getToken method of cordova plugin, 
     "priority" => "high", 
    ); 

    $json_data = json_encode($data); 

    curl_setopt($ch,CURLOPT_HTTPHEADER, $headers); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    $res = curl_exec($ch); 
    curl_close($ch); 

    echo "<pre>" . print_r($res,true) . "</pre>"; exit;//{"multicast_id":xxxx,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidApnsCredential"}]} 

Merci vous.

Répondre

0

Eh bien, je trouve enfin le problème. Sur la console firebase, utilisez toujours votre apple teamID pour le préfixe de l'application même si votre appID a un préfixeID différent de votre numéro d'équipe