Created
March 10, 2018 20:34
-
-
Save ShMcK/d2daf40d3f2fdb3b92f8d6524cdcafc2 to your computer and use it in GitHub Desktop.
simple expo message server demo
This file contains hidden or 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 Expo = require('expo-server-sdk') | |
const expo = new Expo() | |
async function send(messages) { | |
const chunks = expo.chunkPushNotifications(messages) | |
for (const chunk of chunks) { | |
try { | |
const receipts = await expo.sendPushNotificationsAsync(chunk) | |
receipts.forEach(receipt => { | |
if (receipt.status === 'error') { | |
throw new Error(receipt.message) | |
} | |
}) | |
} catch (error) { ... } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment