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?