使用Firebase发送静音推送通知
我想在晚上向用户发送通知.我不想播放任何声音,我只希望用户醒来时能在状态栏上看到它.
I want to send notification at night to the user. I do not want to play any sound, I just want the user to see it on his status bar when he wakes up.
如何在用户设备(Android和ios)上不播放声音的情况下发送推送通知?
How can I send push notification without playing sound on the user device ( both android and ios)?
从Firebase Notification Web控制台:
-
您可以在高级选项中设置
sound = disabled
额外提示:您还可以设置相对于设备的投放类型:例如用户时区的上午8点.
Extra tip: you can also set a delivery type relative to the device: like 8am on the user timezone.
使用Firebase Cloud Messaging API:
-
您可以发送无声音的通知消息:
为此,请不要在notification:{title:``..}
json
,或者您可以发送数据消息: data:{key:value,key2:value2,..}
此消息不会触发任何自动通知,只会触发您的应用回调.然后添加代码以您喜欢的方式创建通知.
or you can send a data-message: data: {key: value, key2: value2, ..}
this message will not trigger any automatic notification, only your app callback. then you add code to create the notification in the way you prefer.
通知消息的参数列表:
https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support
List of parameters for notification-messages:
https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support
在此处阅读有关通知消息和数据消息的更多信息: https://firebase.google.com/docs/cloud-messaging/concept-options
Read more about notification-messages vs data-messages here: https://firebase.google.com/docs/cloud-messaging/concept-options