Jr *_*Pro 12 ios firebase firebase-cloud-messaging firebase-notifications
我在iOS应用程序中使用Firebase推送通知.虽然我能够通过发送以下有效载荷来发送通知,但它在收到时不会发出声音.
{
"to": "myToken",
"notification": {
"body": "test",
"title": "test"
},
"priority": "high"
"sound": "default"
}
Run Code Online (Sandbox Code Playgroud)
如果我从控制台发送测试消息,它运行良好并播放通知声音.
注意:
https://fcm.googleapis.com/fcm/sendkai*_*pai 32
您的JSON "sound" : "default"应该位于"notification"不在JSON根目录中的密钥内.这个JSON应该可行.
{
"to": "myToken",
"notification": {
"body": "test",
"title": "test",
"sound": "default"
},
"priority": "high"
}
Run Code Online (Sandbox Code Playgroud)
Dun*_*nes 11
使用FCM管理SDK时,您必须分别为Android和Apple设备指定声音:
let message = {
notification: {
'body': 'This is the message the user sees',
},
data: {
'param1': 'specify some extra data here',
},
// Apple specific settings
apns: {
headers: {
'apns-priority': '10',
},
payload: {
aps: {
sound: 'default',
}
},
},
android: {
priority: 'high',
notification: {
sound: 'default',
}
},
token: 'target FCM token goes here',
};
Run Code Online (Sandbox Code Playgroud)
(注意:到目前为止我只测试了Apple设置)
payload = {
notification:{
title: 'SOLO has been changed by an administrator',
body: 'Administrator changed your SOLO schedule',
},
android: {
},
apns: {
headers:{
"apns-collapse-id": "solo_changed_administrator",
"content-available": "1",
"apns-priority": "10",
},
payload:{
aps:{
sound: 'default',
badge: 12213123223
}
}
},
data:{
type: 'type'
}
}
Run Code Online (Sandbox Code Playgroud)
https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages?authuser=0#ApnsConfig
| 归档时间: |
|
| 查看次数: |
16930 次 |
| 最近记录: |