0

我嘗試將推送通知發送到我的科爾多瓦IOS應用程序。發送推送IOS上的FCM通知

我使用的插件cordova-plugin-fcm

對於我的Android應用它的工作完美,問題是對於iOS,我的捲曲請求返回:

InvalidApnsCredential

我上傳我的APN關鍵在FCM和這項關鍵工作,因爲我試圖發送一個推送通知只是Apns,它的工作正常我的應用程序收到通知。

這裏APNS腳本誰的工作:http://thrysoee.dk/apns/

這裏我的PHP腳本捲曲用機器人而不是依奧斯FCM至極的工作:

$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"}]} 

謝謝你。

回答

0

那麼我終於找到了問題。在Firebase控制檯上,使用allways即使您的appID具有與您的團隊ID不同的前綴ID,您的蘋果teamID也可用於應用前綴