0

I'm trying to use expo notification service to create push notifications in my app. I followed the setup guide in the official docs: https://docs.expo.dev/push-notifications/push-notifications-setup/

However I'm getting the following error instead of getting the device token:

[Unhandled promise rejection: 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.] at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:106:59 in promiseMethodWrapper at node_modules/expo-modules-core/build/NativeModulesProxy.native.js:15:45 in moduleName.methodInfo.name at node_modules/expo-notifications/build/getDevicePushTokenAsync.js:15:69 in getDevicePushTokenAsync at node_modules/expo-notifications/build/getDevicePushTokenAsync.js:4:53 in getDevicePushTokenAsync at node_modules/expo-notifications/build/getExpoPushTokenAsync.js:9:85 in getExpoPushTokenAsync at node_modules/expo-notifications/build/getExpoPushTokenAsync.js:8:51 in getExpoPushTokenAsync

Environment info:

I'm using expo managed workflow. Expo on version 45.0.0. `

It feels like I should configure my firebase project but I'm still running it on expo go and according to docs, I should only need to do that on build phase. I tried it anyway, but had no success. Also tried reading the provided link on the error and tried to change my firebase init options, but I'm not sure if I did it right.

TonimDev
  • 11
  • 2

1 Answers1

0

You may need to pass the project id while calling getExpoPushTokenAsync() as follows: (Reference: https://github.com/expo/expo/issues/18570#issuecomment-1235788144)

const appConfig = require('../../app.json')
const projectId = appConfig?.expo?.extra?.eas?.projectId;
const expoToken = (await getExpoPushTokenAsync({projectId})).data;