Created
April 30, 2020 00:49
-
-
Save FarazPatankar/d772e658011372b06895754fa05ab284 to your computer and use it in GitHub Desktop.
Push notification configuration for a bare Expo app
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
| import Constants from 'expo-constants'; | |
| import * as Notifications from 'expo-notifications'; | |
| let experienceId = undefined; | |
| // This was a little confusing for me from the docs | |
| // Your experience ID is basically your Expo username followed by | |
| // the slug for the app you need the tokens for. | |
| if (!Constants.manifest) experienceId = '@username/slug'; | |
| // Another thing to note here is that the token is actually under | |
| // the data key. This is different from the managed workflow where | |
| // this method would directly return the token. | |
| const token = await Notifications.getExpoPushTokenAsync({ experienceId }); | |
| // Basically a function that updates the token in your DB | |
| await updatePushToken(userId, token.data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment