【问题标题】:unable to send push notification to ios using fcm token firebase无法使用 fcm 令牌 firebase 向 ios 发送推送通知
【发布时间】:2020-07-27 19:46:14
【问题描述】:

我尝试使用 firebase 通知控制台发送通知,它工作正常,但使用代码会引发错误 {"multicast_id":469219618584251399,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]} 我的代码:-

<?php
define('API_ACCESS_KEY','Server key');

'to'        => $token, //single token
'notification' => $notification,
'data' => $extraNotificationData
];
$headers = [
'Authorization: key=API_ACCESS_KEY',
'Content-Type: application/json'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$fcmUrl);
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($fcmNotification));
$result = curl_exec($ch);
curl_close($ch);
echo $result;

【问题讨论】:

    标签: php firebase push-notification firebase-cloud-messaging


    【解决方案1】:

    我已经解决了。 iOS端生成的token错误。

    以下是之前使用的代码:-

    UIDevice.current.identifierForVendor!.uuidString
    

    现在我正在使用以下代码:-

     Messaging.messaging().fcmToken
    

    【讨论】:

      猜你喜欢
      • 2018-11-27
      • 2019-07-21
      • 1970-01-01
      • 2020-03-29
      • 2022-08-22
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 2019-11-14
      相关资源
      最近更新 更多