Skip to content

Instantly share code, notes, and snippets.

@FarazPatankar
Created April 30, 2020 00:49
Show Gist options
  • Select an option

  • Save FarazPatankar/d772e658011372b06895754fa05ab284 to your computer and use it in GitHub Desktop.

Select an option

Save FarazPatankar/d772e658011372b06895754fa05ab284 to your computer and use it in GitHub Desktop.
Push notification configuration for a bare Expo app
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