1

我正在使用 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); }

  });
4

1 回答 1

0

在 FCM 消息的数据部分:

 ledColor: [240, 0, 45, 1], //show a blinking LED in ARGB color format
于 2019-11-28T14:49:02.847 回答