Generating push token for device using expo push-notification in bare react native

38 Views Asked by At

I am using expo push-notification library to generate device push token and using it to send the notifications to the devices. It is working fine in expo managed workflow but when i am using the function

token = await Notifications.getExpoPushTokenAsync({});

i am getting an error which says :- [Error: Call to function 'ExpoPushTokenManager.getDevicePushTokenAsync' has been rejected. → Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.notifications. Make sure to call FirebaseApp.initializeApp(Context) first.]

Can anyone please tell how to solve this error? I have tried everything but nothing seems to work.

I have tried to initialize the firebase app using the docs but it did not work as expected and it was giving the same error.

1

There are 1 best solutions below

1
nativedev On

You need to pass the projectId in the object. You can find your projectId in app.json.

docs: https://docs.expo.dev/push-notifications/push-notifications-setup/

  await getExpoPushTokenAsync({
    projectId: "your-project-id"
  })