Expokit push notifications on ejected app.. lots of misinformation (even in expo docs) need clarity.


#1

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?

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


#2

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.

Android:

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.


ExpoKIt push notifications - What are you using for IOS and Android
#3

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


#4

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.


#5

Thanks for this.

One more question, did you have to add any code to your react native to listen for notifications?

FCM is messed because when I send a notification it does go through, but when I click on it all it does is open the app and nothing else.


#6

I would think the notification listener (https://docs.expo.io/versions/latest/sdk/notifications#exponotificationsaddlistenerlistener) would work but I haven’t tried it yet.


#7

Ill give it a shot tonight after work and update. thank you


#8

If you are sending notifications with a payload - the listener wont receive it

https://firebase.google.com/docs/cloud-messaging/android/client


closed #9

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