【发布时间】:2017-12-11 15:42:23
【问题描述】:
当我使用 Firebase 控制台时,通过激活“高级选项”下的“声音”,一切都很完美,正如 Mouad Abdelghafour AitAli 在接受的答案 Firebase Push notification is not playing sound when app is in background 中所写的最佳答案所解释的那样。当我使用 cURL 向端点 https://fcm.googleapis.com/fcm/send 发出请求时,我收到了通知,唯一的问题是通知没有播放声音。这就是我从命令提示符发送通知的方式:
C:\curl>curl -k -X POST --header "Authorization: key=<My authorization key>" --header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"to\":\"<Token of device that receives the notification>\",\"notification\":{\"body\":\"Yellow\"},\"priority\":10,\"sound\":\"default\"}"
{"multicast_id":4910170660116070247,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1512975815064180%efad4c69efad4c69"}]}
注意我如何使用\"sound\":\"default\",但通知仍然没有播放声音。正如我所提到的,它可以在 Firebase 控制台上运行,所以我试图理解为什么它不能从命令行使用 cURL。谢谢。
【问题讨论】:
-
@Nilu 我的
AndroidManifest.xml中已经有<uses-permission android:name="android.permission.VIBRATE" />。从 Firebase 控制台发送推送通知时,我已经从 Firebase 控制台启用了声音选项,但正如我在问题中提到的那样,这是可行的,但是当我使用 cURL 从命令提示符发送通知时,声音不会播放。我在我的有效载荷中使用声音键。我已经完成了您分享的链接 (stackoverflow.com/questions/46586215/…) 中的建议。
标签: android firebase curl firebase-cloud-messaging android-push-notification