Firebase Cloud Messaging - 如何向 APN 添加声音
Firebase Cloud Messaging - how to add sound to APN
当使用 HTTP v1 API
向 iOS 设备发送 APN 时,Apple documentation 声明如果 apns-priority
设置为 10
,则
Notifications with this priority must trigger an alert, sound, or badge on the target device
documentation at Firebase 似乎建议添加到 apns JSON 对象:
我只有在 only 设置优先级 JSON POST:
时才成功
"apns": {
"headers": {
"apns-priority": "10"
}
},
当我 POST 按照文档建议执行以下操作时:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"sound": "default"
}
},
...
a 400 - Bad Request
returns 从 FCM 服务器返回。如果我排除 payload
json 部分,则 POST 有效。
还尝试了以下方法:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"sound": "default"
...
仍然收到 400 - 错误请求
How do I set sound on a the APN within the SDK API JSON POST? A default sound is sufficient.
根据您的 JSON,您似乎正在使用 HTTP v1 API。
"apns" 特定词典描述 here。
例如,为了播放默认声音:
...
"apns": {
"headers": {
"apns-priority":"10"
},
"payload": {
"sound":"default"
},
},
...
声音对象需要是 aps
对象的一部分:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"sound": "default"
}
}
},
...
当使用 HTTP v1 API
向 iOS 设备发送 APN 时,Apple documentation 声明如果 apns-priority
设置为 10
,则
Notifications with this priority must trigger an alert, sound, or badge on the target device
documentation at Firebase 似乎建议添加到 apns JSON 对象:
我只有在 only 设置优先级 JSON POST:
时才成功"apns": {
"headers": {
"apns-priority": "10"
}
},
当我 POST 按照文档建议执行以下操作时:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"sound": "default"
}
},
...
a 400 - Bad Request
returns 从 FCM 服务器返回。如果我排除 payload
json 部分,则 POST 有效。
还尝试了以下方法:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"sound": "default"
...
仍然收到 400 - 错误请求
How do I set sound on a the APN within the SDK API JSON POST? A default sound is sufficient.
根据您的 JSON,您似乎正在使用 HTTP v1 API。
"apns" 特定词典描述 here。
例如,为了播放默认声音:
...
"apns": {
"headers": {
"apns-priority":"10"
},
"payload": {
"sound":"default"
},
},
...
声音对象需要是 aps
对象的一部分:
...
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"sound": "default"
}
}
},
...