[英]Send push Notification with FCM on IOS
我嘗試將推送通知發送到我的Cordova Ios應用程序。
我使用插件cordova-plugin-fcm
對於我的Android應用程序,它可以完美運行,問題出在Ios上,我的curl請求返回:
InvalidApnsCredential
我已將我的Apns密鑰上載到FCM上,並且此密鑰有效,因為我嘗試僅使用Apns發送推送通知,並且我的應用程序收到通知后工作正常。
這里是工作的APNS腳本: http : //thrysoee.dk/apns/
在這里,我的帶有FCM的php curl腳本可以在android上使用,但不能在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"}]}
謝謝。
好吧,我終於找到了問題。 在Firebase控制台上, 始終使用Apple TeamID作為應用程序前綴,即使您的appID的前綴ID與teamID不同
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.