Expo Notifications - getExpoPushTokenAsync

Hey guys,

I’ve got a new bare workflow project - and I’m trying to use Expo Notifications (as we did before ejecting) but I’m using a brand new project to prove it out.

  1. Can we still use getExpoPushTokenAsync (I notice we must add an object with experienceId field in it when in Bare)?
    We get the token but cannot send any notifications to it. We’ve done the expo credentials:manager -p ios setup.
    I’ve also stumbled across this thread and have changed the experienceId to be @myUsername/myTestAppSlug but still no avail.

  2. I’ve already gotten getDevicePushTokenAsync working, and have successfully sent a token via another APN service. But ideally I’d like to get ExpoPushToken working as we could then use the same mechanism for android.

  3. Is there any point to getDevicePushTokenAsync in android? I get a token but have no idea how to use it since sending messages with firebase cloud messaging seems to be structured differently than how we interact with Expo.

Thanks guys! Loving the bare workflow minus some quirks but hopefully we can get those figured out.

1 Like

hi there!

  1. yes
  2. good, this works!
  3. if you want the raw token for some reason then you can get it like this, totally depends on what you want to do!

here is an example of a project set up with expo-notifications using the expo push service on ios: GitHub - brentvatne/push-notif-example (i didn’t do android there, that is left as an exercise to the reader! :P)

notice the comment here for more instructions: push-notif-example/App.tsx at f3ad8240166c42863c23a4edff40c2cbae521e18 · brentvatne/push-notif-example · GitHub

edit: you can test it by using Push Notification Tool — Expo once you’ve set it up

1 Like

Glorious Brent. Thank. You. So. Much.

I think my problem was that I wasn’t expo publishing as I was creating new apps only and working with them locally.

Thank you for this!

Hi Brent,

I tried your example and it works.
I can’t get the module working in my bare react-native app. I think I installed the unimodules correctly since Im able to use other modules, and I can also ask Permissions for notifications. But the getDevicePushTokenAsync() is not resolving on my app.

  1. Did you make any specific change for notifications in AppDelegate.m? Im using the recommondation in unimodules documentation (see gist )

Im not using Expo and I want to use my own server.

Thanks in advance.

try comparing the project that i shared above with yours. also ensure you are trying to get the push token on a device

1 Like