15

I am working on react native Expo's Push Notifications. I just started and unable to get the Expo Push notification token. I added the following code:

token = await Notifications.getExpoPushTokenAsync();
console.log(token);

and getting the error "[Unhandled promise rejection: Error: The Expo push notification service is supported only for Expo projects. Ensure you are logged in to your Expo developer account on the computer from which you are loading your project.]".

I am running the project in the Expo App and I have created an account on Expo but still not getting the token. Expo experts, please guide.

Code Lover
  • 723
  • 1
  • 10
  • 24

3 Answers3

38

In your terminal type: "Expo login"

Sign in with your username//password.

Run the project again make sure you use a real device.

Shima K
  • 73
  • 2
  • 2
  • 12
Erik Dreifaldt
  • 773
  • 7
  • 13
2

Register on Expo's official Site. or if you already have an account then...
then from your terminal type expo login
now login using your expo's username, password

after successful login, you are now able to use the expo push notification service.
in the terminal type expo start to start your app dev again!

1

If expo login is not recognized use npx expo login

Adriaan
  • 17,741
  • 7
  • 42
  • 75