javascript - 如果我有令牌数组,通过 FCM 发送通知的最佳方式
问题描述
我能够成功地将通知发送到单个令牌。
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....]
我必须遍历数组还是有其他方法?还有一件事我的通知既没有出现在锁定屏幕上,也没有在手机解锁时弹出。图像出现在顶部,我必须滚动通知托盘/菜单。如何解决这个问题?
解决方案
推荐阅读
- json - React 在 PUT 上发送一个空的 JSON 对象
- routes - 部署到 Netlify 时,Sapper Svelte 路由不工作并且页面丢失
- r - Apriori 模型没有显示出明显的关联
- ruby-on-rails - Rails 获取参数在生产中为零
- sql - 在 LIKE 函数中使用正则表达式进行 SQL 查询
- python - Discord bot(on_message 事件不会让命令工作*)
- node.js - 如何在没有两个查询的情况下在 Knex 中执行此操作
- java - 如何以编程方式设置属性的值
- python - 下载带有请求的大文件时遇到问题?
- xcode - 'EXUpdates/EXUpdatesAppController.h' 文件未找到 XCODE