I'm using com.google.firebase:firebase-messaging:10.0.1
for Android and trying to make the device vibrate while application is in background and a push notification is received.
I send following json to FCM server:
to: 'topics/...',
notification: {
title: 'New Message',
body: 'top security body',
sound: 'mysound',
action_click: 'top_security'
}
When the app is in foreground, the onMessageReceived
method of FirebaseMessagingService
is triggered and I can add vibration. But, when the app is in background, onMessageReceived
is not called and I have no control on the vibration. My first thought was to use data
block instead both for background and foreground, but iOS client does not receive pushes in background if there is no notification
block.
So how can I add vibration to push notification when the app is in background? P.S. When I turn on vibrate mode on the device, the push notification cause vibrating instead of playing the sound.