如果我有令牌数组,则通过FCM发送通知的最佳方法

时间:2018-10-10 12:16:31

标签: javascript firebase firebase-cloud-messaging

我能够将通知成功发送到单个令牌。

 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....]

我必须遍历数组或还有其他方法吗? 还有一件事,我的通知既没有显示在锁屏上,也没有在手机解锁时弹出。图片显示在顶部,我必须滚动通知托盘/菜单。该如何解决?

0 个答案:

没有答案