ios - iOS、Node.js:Firebase 推送通知 JSON 签名
问题描述
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);
});
怎样做才能工作?
解决方案
我从 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
}
}
}
}
推荐阅读
- python - Convert HMAC Hash from Python to PHP
- flutter - Firestore Multiprovider 不适用于身份验证
- python - In Python, how to map multiple item to one function/value?
- python-3.x - Selenium to load web page at server side without chrome browser
- javascript - discord.js/voice 库不工作
- laravel - 我正在尝试使用 laravel 7 显示与菜单类别相关的产品名称
- model-view-controller - pecl:找不到命令
- android-studio - 如何在 Android Studio 中将代码粘贴到光标位置?
- node.js - TypeError:无法读取未定义的属性“发送”-discord.js
- javascript - 如何将按钮 ID 的值传递给 GET 请求?