Created
December 23, 2017 09:05
-
-
Save n1lesh/4c1957899dc70db723aad972047f1163 to your computer and use it in GitHub Desktop.
Firebase Cloud Messaging with Node.js - FCM 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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