Created
January 23, 2019 06:48
-
-
Save aloukissas/2369332c3a8c12887451081edffcbf85 to your computer and use it in GitHub Desktop.
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
import { Notifications, Permissions } from "expo"; | |
const PUSH_ENDPOINT = "https://your-push-server/push-token" | |
async function registerForPushNotificationsAsync() { | |
// Request permissions -- same as earlier | |
[...] | |
// Get the token that uniquely identifies this device | |
const token = await Notifications.getExpoPushTokenAsync(); | |
// POST the token to your backend server from where you can retrieve it to send push notifications. | |
return fetch(PUSH_ENDPOINT, { | |
method: "POST", | |
headers: { | |
Accept: "Content-Type": "application/json", | |
}, | |
body: JSON.stringify({ | |
token: { | |
value: token, | |
}, | |
user: { | |
userId: "current_user_id", | |
}, | |
}), | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment