Expo-Notifications with FCM / APNs

  1. SDK Version: 40
  2. Platforms(Android/iOS/web/all): Android ( and soon iOS )

As far as I understand the docs …
The worflow in order to get push notifications on my apps is :

Solution A :

Solution B :

  • BackEnd Action that trigger à POST to https://fcm.googleapis.com/fcm/send
  • FCM receive that post which contains the “to” field which is the Notifications.getDevicePushTokenAsync() of my device.
  • FCM triggers the notification on the device.

I have severals questions about theses worflows …
Does the solution A implies the Expo servers ? Does it still work on production with a builded .apk then ?

Does the solution B implies the Expo servers at all ? Then the getDevicePushTokenAsync isn’t related to Expo ? If no then why we should provide the “experienceId” field which is for sure linked to expo regarding this doc

So that not very clear (despite all the docs that I’ve read 3 times each) how I can implement push notification with expo and FCM / APNs

There are 3 options for sending push notifications:

Expo’s push notification servers do indeed work with production apps, you just need to set up the credentials which we have guides for: Push notifications setup - Expo Documentation

Does the solution B implies the Expo servers at all ? Then the getDevicePushTokenAsync isn’t related to Expo ? If no then why we should provide the “experienceId” field which is for sure linked to expo regarding this doc

No, it doesn’t use Expo’s servers, and getDevicePushTokenAsync does not require the experienceId so I’m not sure what you mean

1 Like

I mean in this section of the doc there’s an example of a POST call ( using fetch API ) to the FCM in order to let him trigger a push notification ( If I get it well )

In this post call there’s the to: '<NATIVE-DEVICE-PUSH-TOKEN>', field which I assume is the result of getDevicePushTokenAsync BUT there’s also in the data object the experienceId: '@yourExpoUsername/yourProjectSlug',

To clarify ( 'cause I know I’m not very clear haha ).
I would like to get some notifications on my app only triggering some POST call to my FCM is this even the right way to do so ? :sweat_smile:
I don’t want to / can’t really use Expo’s notifications server has I’m working for a client which is in charge of the back end part and won’t use expo.

It’s not very clear which are the steps to get thoses notifications working.
I’ve succeed to get notification from the expo notification tools ( using the register function from the setup docs )

But, I’ve then download google-service.json, linked it in my app.json and changed the register function with getDevicePushTokenAsync but I can’t receive any notification.

Maybe It’s a send problem… I’ve try through the firebase console with no luck :

I also tried to send that POST request which I was talking about previously with postman and getting a MismatchSenderId error

Do you have some clues for me ?

EDIT
While testing again in order to make the screens for you it seems that it just WORKED ! ( Through the firebase console )
There’s maybe some kind of delay after creating a firebase project … :thinking:
So my concern is just that MismatchSenderId error …
I understand that it needs to be in a standalone app in order to try it …

But why I’ve got this missmatch error ? What does not match ? I found my “senderId” in my firebase console… But what should I do with it ? As far as I understand the firebase docs the DevicePushToken is somehow linked to the senderId ?

EDIT Bis
So I’ve got it working … Some notes :
The DevicePushToken is different when got from the metro bundler and got from a .apk build ! This explain the MismatchSenderId error…

So my last question is : Why I still need that data.experienceId in my post request to https://fcm.googleapis.com/fcm/send it already have the device token no ? Indeed If I delete this field the notification doesn’t trigger…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.