getDevicePushTokenAsync failing on Android build
See original GitHub issueSummary
Getting the following error when trying to get expo push notification token on Android build. It is working fine on iOS.
Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Please set your project ID. A valid Firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Google.
I am not using firebase anywhere in my app. I have followed expo documentation for setting up notifications on the managed workflow (I got the registerForPushNotificationsAsync function in my code straight out of expo docs).
app.json :
"android": {
"softwareKeyboardLayoutMode": "pan",
"useNextNotificationsApi": true,
"versionCode": 400020160,
"package": "com.package.name",
"playStoreUrl": "https://play.google.com/store/apps/...",
"icon": "assets/images/icon.png",
"adaptiveIcon": {
"foregroundImage": "assets/images/....png",
"backgroundColor": "#FFF"
},
"config": {
"branch": {
"apiKey": "ewfewfwe"
},
"googleMaps": {
"apiKey": "wefweewr"
}
}
}
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)
40
Environment
Expo CLI 4.1.6 environment info: System: OS: macOS 11.2.1 Shell: 5.8 - /bin/zsh Binaries: Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 12.4/12D4e - /usr/bin/xcodebuild npmPackages: expo: ^40.0.0 => 40.0.0 react: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2 react-navigation: ^3.13.0 => 3.13.0 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
- Add expo-notifications and getDevicePushTokenAsync to a managed expo project
- Build and deploy Android
- getDevicePushTokenAsync returns an error
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:27 (2 by maintainers)
Top Related StackOverflow Question
@classiebit We ended up doing the Firebase setup, which fixed things.
In the
expo-notificationspackagegetExpoPushTokenAsyncactually needs adevicePushToken(the one you get from Apple/Google) to work. If you don’t pass one explicitly, it fetches it automatically.https://github.com/expo/expo/blob/5e0a6bc252aa05e5fa5ea371169d01902ba6bb1a/packages/expo-notifications/src/getExpoPushTokenAsync.ts#L28-L30
The SDK upgrades didn’t mention needing to configure a Firebase project to upgrade from the legacy notifications module, to
expo-notifications, but the current docs for FCM Push make it clear that all Expo apps need it unless they are running in Expo Go (which is why we couldn’t repro the error in development).Finally found the spot in the docs where they mention it explicitly, too: https://docs.expo.io/push-notifications/push-notifications-setup/
No idea why this wasn’t flagged as a breaking change, unless we missed something previously and should have had this configured previously.
Same for me