Skip to content

Instantly share code, notes, and snippets.

@moduscreate
Created February 16, 2018 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moduscreate/f4909201bd803568c5050f549d22c1ab to your computer and use it in GitHub Desktop.
Save moduscreate/f4909201bd803568c5050f549d22c1ab to your computer and use it in GitHub Desktop.
Expo Notifications Demo - registerForPushNotifications
async registerForPushNotifications() {
const { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
return;
}
}
const token = await Notifications.getExpoPushTokenAsync();
this.subscription = Notifications.addListener(this.handleNotification);
this.setState({
token,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment