I think there is a bit of confusion whats online and also whats being said in the expo forums. I was wondering if someone can clear this for me.
I had to eject to use the payment module, when I ejected my notifications stopped working. It was confirmed on the forums that push notifications dont work on ejected apps by an Expo team member here Push Notifications with ExpoKit - advice? - #34 by ide
NOW, yesterday I started working with react push notification zoor library - on Android. After setting everything in my android manifest and setting up fcm and such, I was able to get a Device token (not expo token). After a while of more tinkering around, I still had some old expo push notification code lying around. AND I started getting expo tokens as well - I can send push notifications using that expo token to the device on an ejected app. So my question is
Do expo push notifications work on an ejected app or not? Or is this a one time thing - I’d rather use expo notifications as they ARE way easier to use than anything outthere
As far as I know, the Expo push notification service/ tokens wouldn’t work once you’ve ejected.
One nice thing about Expokit is that it already has push notification libraries built-in (it needs them because Expo push notifications eventually become APNS/ FCM/ GCM behind the scenes). I don’t recall this being well-documented in the Expo doc, but I was able to get them working in Expokit. As I recall the steps were:
iOS:
Just add the push notification entitlement to your Expo client. You’ll notice in AppDelegate.m that all of the push notification delegate methods are already wired up.
No need to edit any other Java- those code paths are executed based on the FCM_ENABLED flag.
Hopefully I’m not missing any steps there- it’s been a little while since I did this.
Then, in your JS, you can import Expo.Notifications, and call Notifications.getDevicePushTokenAsync() to get your native token and do whatever you need to do with it.
Thanks for your answer- I am not a pro at android or iOS … so when you say the methods are already setup do you mean code to read these notifications and the payload?
I was able to get expo token yesterday on my ejected app so was wondering if that’s all I need? So I don’t have to worry about setting up another library
Thanks for your answer- I am not a pro at android or iOS … so when you say the methods are already setup do you mean code to read these notifications and the payload?
Yes, basically. If you read further down that FCM tutorial or look at how to configure APNS in an iOS app, you’ll see a bunch of Java or Objective-C you need to add - interacting with notification manager or overriding delegate methods that are called when notifications are received. Normally, you’d have to do all that, but ExpoKit already has push notification libraries and they’ve already been wired up in the native code. You just need to add some configuration (AndroidManifest.xml, setup some flags, app entitlements, etc.) to tell your app to start accepting push notifications.
I was able to get expo token yesterday on my ejected app so was wondering if that’s all I need? So I don’t have to worry about setting up another library
You’ll want to use the native push token - not the Expo push token. In ExpoKit, you will no longer be using Expo’s servers as an intermediary.