Mag*_*nus 6 node.js firebase firebase-cloud-messaging firebase-admin
在网上搜索了几个小时以获取有关如何在 Firebase 云消息通知上启用默认声音的答案后,对于 Android 和 iOS,我终于自己弄明白了。我在网上的任何地方都找不到这个问题的任何答案,所以我想我应该在这里发布答案。
希望这可以帮助 :)
Mag*_*nus 17
这个特定的片段是用 node.js 编写的,但除了前 3 行之外,语法在 Typescript 中是相同的。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const payload = {
notification: {
title: "X",
body: "XXX",
},
android: {
notification: {
sound: 'default'
},
},
apns: {
payload: {
aps: {
sound: 'default'
},
},
},
topic: 'X'
};
return admin.messaging().send(payload).then(response => {
console.log("Successfully sent message:", response);
})
.catch(function (error) {
console.error("Error sending message:", error);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6544 次 |
| 最近记录: |