简体   繁体   中英

Deliver a notification with vibration, LED light, sound using FCM

I have implemented the sample Firebase code from here to see if it works with my project.

I receive a notification when my app is killed or closed once the database child value changes, all is good, but how do I set the vibration, sound and led light blinking function using code from here ? Do I need to detect the notification with android or I have to implement it with the payload somehow?

在 FCM 消息的数据部分添加:

 ledColor: [215, 138, 138, 1], //show a blinking LED in ARGB format

AFAIK, the vibration and LED option is set by the user itself (ie it's a setting within the device). The user is the one to choose if any notification should produce a vibration and/or trigger the LED notifier. But it seems that you could build a notification that triggers a vibration as well. See this post for more details.

For the sound however, you could simply make use of the sound parameter:

The sound to play when the device receives the notification.

Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM