【问题标题】:iOS, Node.js: Firebase Push Notification JSON signatureiOS、Node.js:Firebase 推送通知 JSON 签名
【发布时间】:2020-05-27 07:26:25
【问题描述】:

Firebase 文档要求像这样实现,它会在 node.js 服务器上获得成功返回值。但是通知没有送达。

从 Firebase 云消息传递控制台,所有通知/消息都会被传递。 除了以下情况,普通的 APNS 也可以使用。

此特定 JSON 签名不会向 APNS 确认。当我提供与 APNS 兼容的 JSON 时,Firebase 会返回错误。

// This registration token comes from the client FCM SDKs.
var registrationToken = 'YOUR_REGISTRATION_TOKEN';

var message = {
  data: {
    score: '850',
    time: '2:45'
  },
  token: registrationToken
};

// Send a message to the device corresponding to the provided
// registration token.
admin.messaging().send(message)
  .then((response) => {
    // Response is a message ID string.
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

做什么才能工作?

【问题讨论】:

  • 请看我的回答。

标签: ios swift firebase firebase-cloud-messaging


【解决方案1】:

我是从 Google 的 Firebase 示例代码中找到的。而且,它有效。

{
        "token": "<<YOUR FCM TOKEN>>",
        "notification": {
            "body": "Notification from FCM",
            "title": "FCM Notification"
        },
        "android": {
            "notification": {
                "click_action": "android.intent.action.MAIN"
            }
        },
        "apns": {
            "headers": {
                "apns-priority": "10"
            },
            "payload": {
                "aps": {
                    "badge": 1
                }
            }
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 2017-04-19
    • 2011-08-07
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    相关资源
    最近更新 更多