【问题标题】:set LED light to android notification with firebase FCM使用firebase FCM将LED灯设置为android通知
【发布时间】:2019-04-13 19:15:41
【问题描述】:

我正在使用 firebase fcm 将通知推送到我的 android 应用程序。 我有两种情况:

  1. 当应用程序在前台时:我在 onMessageReceived 方法中收到消息
  2. 当应用程序在后台时:firebase 向我的设备推送通知,所以我想在通知中添加 LED 灯,并且我想振动设备。

我使用firebase云功能

    request({
    url: 'https://fcm.googleapis.com/fcm/send',
    method: 'POST',
    headers: {
      'Content-Type' :' application/json',
      'Authorization': 'key='+"" },
    body: JSON.stringify({

      data: {
    title: 'Your app',
    message: "",
    body:""
  },to : ""})
  }, function(error, response, body) {
    if (error) { console.error(error); }

  });

【问题讨论】:

  • 设置 LED 通知是设备特定的。您可以在手机的设置中进行这些设置。
  • 在我的设备中,我有其他应用程序使用 LED 推送通知。但只有我的不显示光

标签: android firebase push-notification firebase-cloud-messaging


【解决方案1】:

在 FCM 消息的数据部分:

 ledColor: [240, 0, 45, 1], //show a blinking LED in ARGB color format

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多