我正在使用 firebase fcm 将通知推送到我的 android 应用程序。我有两种情况:
- 当应用程序在前台时:我在 onMessageReceived 方法中收到消息
- 当应用程序在后台时: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); }
});