Firebase Cloud Message Vibration Notification

Is it possible to make an Android device vibrate when it receives notifications in the background using Firebase Cloud Messaging? From the Syntax Reference, I saw and tested that sound is supported, but there is no vibration information. Or can you somehow provide an individual implementation of this notification, where I would directly set the vibration?

+8
android push-notification firebase-cloud-messaging
source share
3 answers

From what I tested, the FCM notification message format seems pretty tough, so for individual notifications, the solution is as follows:

  • Making sure that the payload of the JSON message sent downstream contains the data parameter but does not contain the notification parameter (Sources: Message JSON Syntax , FCM message types )
  • Creating a notification in the implementation of the overridden onMessageReceived(RemoteMessage remoteMessage) from the FirebaseMessagingService application ( Example )
+7
source share

You should mark yourself as the correct answer.

In a side message, if you send the message "Notification" and "Data", use

 "notification":{ "sound":"default" } 

This will produce sound when the application is in the background and the device is set to sound and it will vibrate if the device is configured to vibrate.

However, as far as customization is concerned, I think you need to use Data Data Load only if you want to customize the vibration pattern, for example.

+15
source share

array("title"=>"hello","body" =>"hello world",'sound' => 'default')

-one
source share

All Articles