Firebase 云消息通知振动 [英] Firebase Cloud Messaging Notification Vibration

查看:30
本文介绍了Firebase 云消息通知振动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Firebase 云消息传递在后台接收通知时使 Android 设备振动?从 Syntax Reference 我见过并测试支持声音,但没有关于振动的信息.或者是否可以为此通知提供自定义实现,我将直接设置振动?

Is it possible to make an Android device vibrate when receiving notifications in the background with Firebase Cloud Messaging? From the Syntax Reference I have seen and tested that sound is supported, but no info on vibration. Or is it somehow possible to provide a customized implementation for this notification where I would directly set the vibration?

推荐答案

从我测试的 FCM Notification 消息的格式来看,似乎相当死板,所以对于自定义通知,解决方案似乎是:

From what I have tested the format of the FCM Notification message seems to be quite rigid, so for customized notifications, the solution seems to be:

  1. 确保向下游发送的 JSON 消息的负载包含 data 参数但包含 notification 参数(Sources:消息 JSON 语法FCM 消息类型)
  2. 在应用程序的 FirebaseMessagingService (示例)
  1. Making sure that the payload of the JSON message being sent downstream contains the data parameter but doesn't contain the notification parameter (Sources: Message JSON Syntax, FCM Message Types)
  2. Creating the Notification in the implementation of the overridden onMessageReceived(RemoteMessage remoteMessage) from the application's FirebaseMessagingService (Example)

这篇关于Firebase 云消息通知振动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆