expo: expo-notifications failing to get token
Summary
I am having issues with expo-notifications.
So I created a blank project with the expo init command, created a managed workflow, and installed expo notifications via expo install.
Then I copied the registerForPushNotificationsAsync from here, used it in a useEffect hook and got the following error:
[Unhandled promise rejection: Error: Fetching the token failed: java.util.concurrent.ExecutionException: java.io.IOException: AUTHENTICATION_FAILED]
Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
45
Environment
expo-env-info 1.0.5 environment info: System: OS: Windows 10 10.0.22000 Binaries: Node: 16.16.0 - C:\Program Files\nodejs\node.EXE npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD npmPackages: expo: ~45.0.0 => 45.0.6 react: 17.0.2 => 17.0.2 react-dom: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-web: 0.17.7 => 0.17.7 Expo Workflow: managed
Reproducible demo
https://docs.expo.dev/versions/latest/sdk/notifications/#api
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 16
- Comments: 91 (8 by maintainers)
I found a workaround for this issue. If the problem is that expo-notifications can’t find the projectID, just supply it:
This is working for me, and will enable me to keep developing and testing my notifications code, although I don’t feel like it should be necessary for production code, and I’m hoping that a proper fix is on the way.
I still keep getting this problem. asap update pleeeese
same here with slightly different error message_
Fetching the token failed: Please set your Project ID. A valid Firebase Project ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.Note: If we push to prodution then everything works. this is only an issue in expo go
Hi, I had same issue with
No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.when using EAS with developmentClient. When using Expo GO or standalone build with AES(“distribution”: “internal”) everything works OK.To get it working I did add parameter experienceId, like:
const token = (await Notifications.getExpoPushTokenAsync({experienceId: "@username/projectSlug"})).data;as mentioned at the docs https://docs.expo.dev/versions/latest/sdk/notifications/#getexpopushtokenasyncoptions-expotokenoptions-expopushtokenexperienceId (string) -- Although this is optional, we recommend explicitly passing it in. The ID of the experience to which the token should be attributed. Defaults to [Constants.manifest.id](https://docs.expo.dev/versions/latest/sdk/constants/#constantsmanifest) exposed by expo-constants. When building with EAS Build, or in the bare workflow, this is required and you must provide a value which takes the shape @username/projectSlug, where username is the Expo account that the project is associated with, and projectSlug is your [slug from app.json](https://docs.expo.dev/versions/latest/config/app/#slug).I have checked that in EAS build with developmentClient Constants.manifest.id is undefined
Solution by @TheRealMikeD works also👍
Thank you! For Expo SDK 47 and up:
I am running into the exact same problem. Running on a development build on my iPhone on SDK 46. Getting a 401 when calling
getExpoPushTokenAsyncLooks like patch is on the way!
https://github.com/expo/expo/pull/18652
I can confirm this is fixed in expo go 2.25.2 - which is already in the play store. Thanks a lot!
I still keep running into this error in production. Am I alone? I tried a bunch of things that people suggested around here, but nothing seems to do the trick. More specifically, I keep getting
Error: Fetching token failed: java.io.IOException: FIS_AUTH_ERRORwhen callinggetExpoPushTokenAsync.Please somebody gives this man a beer
Running into the same issue on expo go app in dev mode on android. I am using managed workflow. Expo go app version: 2.25.2
error notification Error: No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.code:
Edit: Running
eas initfixed it. It added a projectId to app.json and nowNotifications.getExpoPushTokenAsync()works Thanks @usmangurowaSo I spent the whole of last night trying to fix this issue, I almost gave up when I saw the Expo Team comments. Hopefully this afternoon (it’s afternoon over here). I run
eas initand this seems to fix the issue. I think the problem was because there is no projectId in the app.json file, runningeas initwill fetch the ID from your expo app hosted on the expo.dev site and add it to your app.json. Now I can get the push tokens.Yes the problem is with expo go version=>2.25 And the solution is
Everything works fine on Expo Go app now, but I still get the error
[Error: No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.]after building a dev client witheas build --profile development --platform android.Anyone else experiencing the issue with development builds? Works fine on preview and production builds
I think for me it doesn’t work even in production (I tried using an eas build yesterday).
Yep. Same problem. The latest expo go from the app store works, but dev clients built with
run:android/run:iosdo not appear to. I’m guessing an update isn’t pushed out for the dev client code / generation that was required in expo go.Version 2.24.6 is working fine. You’ll need to downgrade…
And in case anyone else runs into this — even though I had the same Google API key and google-services.json for dev and production, the API key was restricted to only the package fingerprint of the Expo-built Google Play-released version of the package. I had to extract the key of the development build by downloading the APK from the expo.dev builds page and running
keytool -printcert -jarfile application.apk | grep SHA1and then adding that to the API key restrictions. I’m not sure how long it took to update becausegetExpoPushTokenAsync()didn’t work at the end of the day but started working the next morning.Rotated our
google-services.jsoncreds and PNs are now working again. Not clear to me if this is a Google issue or an Expo issue.Anyways I suspect that this issue is full of lots of people with different root issues that surface similarly.
This worked perfectly 👍
Same problem for me when running
eas build --profile developmentAaaand 17 minutes after I posted that, I realized our error: We used a different API key for development than for production, and the API key I had didn’t match the one in google-services.json. Works for us now.
This is happening for us, too. We didn’t change a thing about our configuration and Android simply stopped being able to get a token.
getDevicePushTokenAsync()fails withError: Fetching the token failed: java.util.concurrent.ExecutionException: java.io.IOException: FIS_AUTH_ERROR.I’ve double checked all of our service accounts, API keys,
google-services.jsonfiles, expo.dev settings, and everything matches up. My suspicion is that keys somewhere in Google’s system tend to expire, and I wonder if I redo everything if I’ll be able to get it all working again.This is not something I want to do late at night when I get paged because our users aren’t getting notifications.
I also experience this even though I have updated
expo-dev-clientto1.2.1Same error - downgrading to 2.24_6_free (link above) worked fine. Alternatively where is it looking for the firebase project ID? And could this be manually set as a temporary workaround?
The link works, and downgrading does indeed solve the issue. Thanks!
@claudionhangapc I have downloaded the 2.23.2 version of Expo Go for android. And it worked.
@Tasluf665 yes you are right, the problem in the update of expo go, when I downgrade to Expo 2.24.6 everything is working fine and there is no issues with notifications, I got device push token registered successfully
@brentvatne
I think this problem might be in expo go. After the new update, I am facing this problem. I try to install the expo-notifications older version, but the same problem occurred in the expo go. But after building it by expo build:android it works fine on apk.
I am getting this error as well on Expo 46 with expo-ci 6.0.2
Error: Fetching the token failed: Please set your Project ID. A valid Firebase Project ID is required to communicate with Firebase server APIs: It identifies your application with Firebase.Please refer to https://firebase.google.com/support/privacy/init-options.]Everything was working fine with Expo SDK 44 and expo-notifications (which was configured with the FCM project and includes the google-services.json per the Expo docs), then I upgraded to 46 and get that error with testing in the Expo Go app that uninstalled/reinstalled to have a clean slate to work with.