Skip to content

Instantly share code, notes, and snippets.

@n1lesh
Created December 23, 2017 09:05
Show Gist options
  • Save n1lesh/4c1957899dc70db723aad972047f1163 to your computer and use it in GitHub Desktop.
Save n1lesh/4c1957899dc70db723aad972047f1163 to your computer and use it in GitHub Desktop.
Firebase Cloud Messaging with Node.js - FCM 5
const sendToAll = (msg, title, regIdArray, response) => {
const data = {
"data": {
"body": msg,
"title": title
}
}
const folds = regIdArray.length % 1000
for (let i = 0; i < folds; i++) {
let start = i * 1000,
end = (i + 1) * 1000
data['registration_ids'] = regIdArray.slice(start, end).map((item) => {
return item['token']
})
sendNotifications(data)
}
response.sendStatus(200)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment