【发布时间】:2017-03-02 12:44:37
【问题描述】:
我在 Android 上使用 com.google.firebase:firebase-messaging:10.0.1,并尝试在应用程序处于后台并收到推送通知时使设备振动。
我将以下 json 发送到 FCM 服务器:
to: 'topics/...',
notification: {
title: 'New Message',
body: 'top security body',
sound: 'mysound',
action_click: 'top_security'
}
当应用在前台时,触发FirebaseMessagingService的onMessageReceived方法,我可以添加振动。但是,当应用程序在后台时,onMessageReceived 不会被调用,我无法控制振动。我的第一个想法是在后台和前台都使用data 块,但是如果没有notification 块,iOS 客户端不会在后台接收推送。
那么当应用程序在后台时,如何为推送通知添加振动? 附言当我在设备上打开振动模式时,推送通知会导致振动而不是播放声音。
【问题讨论】:
-
因为您应该发送静默通知,请关注此link
-
请参考我在此链接中的回答,stackoverflow.com/a/42505362/1404798
-
@mahmoudmoustafa 我用的是安卓,看标签
-
另请参阅此答案和this answer 和this answer
标签: android firebase push-notification firebase-cloud-messaging