我正在使用com.google.firebase:firebase-messaging:10.0.1
来开发Android应用程序,并尝试在应用程序处于后台且接收到推送通知时使设备振动。
我向FCM服务器发送以下JSON:
to: 'topics/...',
notification: {
title: 'New Message',
body: 'top security body',
sound: 'mysound',
action_click: 'top_security'
}
当应用程序处于前台时,将触发
FirebaseMessagingService
的onMessageReceived
方法,并且我可以添加振动。 但是,当应用程序在后台运行时,onMessageReceived
不会被调用,并且我无法控制振动。 我最初的想法是对于背景和前景都使用data
块,但是如果没有notification
块,iOS客户端在后台不会收到推送。
那么,当应用程序在后台运行时,如何在推送通知中添加振动? 附注:当我在设备上打开振动模式时,推送通知会导致振动而不是播放声音。