1

I am able to send notification successfully to single token.

 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)
        })

And sendTo is now array of token

var sendTo = [T1,T2,T3....]

I have to loop over array or is there any other way? And one more thing my notifications are neither appearing on lock-screen nor popping out when phone is unlock. Image appear at the top and I have to scroll the notification tray/menu. How to solve this?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Rajan Lagah
  • 2,373
  • 1
  • 24
  • 40
  • 1
    can you give us more detail ? Which node module do you use to connect to the FCM api ? – MaieonBrix Oct 10 '18 at 12:18
  • @MaieonBrix i just edited my question and I am using axios for post request to fcm. – Rajan Lagah Oct 10 '18 at 12:21
  • Hi Rajan. You have primarily two options. First is to use topics messaging. Second (only if you're using Legacy FCM) is to use `registration_ids` instead of `to` -- keeping in mind that it has a 1000 tokens limit *per request*. – AL. Oct 11 '18 at 09:20

0 Answers0