我能够将通知成功发送到单个令牌。
var body = {
to: sendTo,
data: {
custom_notification: {
title: "New notification",
body: 'msg',
sound: "default",
priority: "high",
show_in_foreground: true,
targetScreen: "detail"
}
},
priority: 10
}
axios({
method: 'post', //you can set what request you want to be
url: 'https://fcm.googleapis.com/fcm/send',
data: body,
headers: {
"Content-Type": "application/json",
"Authorization": "key=" + serverKey
}
}).then((res)=>{
console.log(res)
}).catch((e)=>{
console.log(e)
})
sendTo现在是令牌数组
var sendTo = [T1,T2,T3....]
我必须遍历数组或还有其他方法吗? 还有一件事,我的通知既没有显示在锁屏上,也没有在手机解锁时弹出。图片显示在顶部,我必须滚动通知托盘/菜单。该如何解决?