Push Notifications with ExpoKit - advice?

  1. What I meant by legal limitations is that OneSignal has access to a LOT of business data and perhaps even sensitive data, they even say so themselves on their website:

“Best of all, OneSignal is a free service that supports unlimited devices and notifications. OneSignal makes money by selling data to advertisers and research companies. We also offer paid service options for clients that require increased data privacy.”

  1. I can’t use Expo’s Push Notifications because my app is detached :frowning:

Yeah it works on my iOS ExpoKit (detached) app :slight_smile:

I guess you will need to be aware of what data they have access to and perhaps include that in your app’s terms of service? It’s a good point.

Hi I noticed you asked about react-native-fcm earlier. Has anyone been able to make this work using ExpoKit?

I’ve had to detach due firebase not working with Expo Push Notifications. :slightly_frowning_face:

@jaclynjessup I think that the only push notification working with ExpoKit is react-native-onesignal with cocoapod approach

Out of interest, has anyone been able to get it working on Android? That was supposed to be the easy part. Following the instructions on the react-native-onesignal readme and once I build the project, it starts up and then crashes every time.

https://github.com/geektimecoil/react-native-onesignal#android-installation

The output in Android Studio’s logcat is below. Unfortunately I don’t know enough about working in Android Studio but it looks like maybe the app can’t connect with expo XDE anymore? I don’t see any output in XDE which would suggest the same.

FWIW I recently upgraded expo kit to release 20 but I am able to run the app until I start to try and set up OneSignal.

08-29 08:41:12.036 17819-17994/com.cure8.cure8app E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
                                                                    Process: com.cure8.cure8app, PID: 17819
                                                                    java.lang.NullPointerException: Attempt to invoke interface method 'void host.exp.exponent.experience.DevBundleDownloadProgressListener.onProgress(java.lang.String, java.lang.Integer, java.lang.Integer)' on a null object reference
                                                                        at versioned.host.exp.exponent.ExponentDevBundleDownloadListener.onProgress(ExponentDevBundleDownloadListener.java:27)
                                                                        at com.facebook.react.devsupport.DevSupportManagerImpl$22.onProgress(DevSupportManagerImpl.java:819)
                                                                        at com.facebook.react.devsupport.BundleDownloader$1$1.execute(BundleDownloader.java:122)

@ianlenehan I’m also interested in this
@nirpeled did you get oneSignal working on android?

No, I haven’t tried OneSignal on Android but it works great on iOS

ok thanks, got it working already on android

Hey @flieks - for Android, the readme for react-native-one-signal is a little confusing. For example, it says in android/gradle/wrapper/gradle-wrapper.properties to add:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip

Well my file has all that, except the distributionUrl is for gradle-3.3-all.zip. I can’t work out if their recommendation of a lower version is just the minimum, or if I have to go with that exact version.

Same thing for android/build.gradle they have classpath 'com.android.tools.build:gradle:2.2.2' // Upgrade gradle. But upgrade gradle? Mine already says 2.3.3, so again it’s a higher version.

Same again for build tools in android/app/build.gradle, their documentation has a lower version than mine does.

What did you end up doing?

Did you get it working on Android @martinezguillaume?

I opened the project in Android studio, I put gradle version in
android/build.gradle to 2.2.3 then android studio sync your project
automatically !

Interesting. I ended up completely removing expo kit and was able to get it working fine - I figured in the end it’s not worth keeping there. So I’m back to pure RN!

Hey all,

I have some questions closely related to this that I thought might be appropriate here. I’m trying to implement a custom notifications solution with react-native-push-notifications purely for the purpose of providing a custom sound since Expo.Notifications doesn’t allow for it. These notifications are strictly local and therefore don’t require a server.

https://github.com/zo0r/react-native-push-notification

In going through the process of detaching and adding a third-party library I’ve hit a lot of snags. Below I’ve listed some questions I’ve had at each stage of the process (so some answers to earlier questions may become irrelevant as others that come along later are answered). I’m hoping your answers may help me (and others) successfully detach and implement a third-party notifications library (or others) in the future.

  • Does anyone have any clarity on using Expo.Notifications when detached vs. ejected? I’ve seen some say that you can’t use them detached (aka with ExpoKit), and others say it’s only when fully ejected. I figure they work with ExpoKit just fine? I ask because if you do detach and would like to use other notification services, would you want to make sure you’ve removed the use of Expo.Notifications first so native code doesn’t make it into the project? I was getting build errors almost immediately and I could see ExpoKit put some native notifications code in the AppDelegate.m file that were later duplicated by the third-party library.

  • In the instructions for the notification library above it says I should use react-native link, which makes sense because from what I can tell this library doesn’t have a .podspec and shouldn’t be installed by running pod install, but can anyone confirm? It seems weird that they also link you to instructions to manually link PushNotificaionIOS and I’m afraid wires are getting crossed there.

  • After manually linking the library (dragging the Library into the Libraries directory, adding its .a file as linked library, modifying the Search Header Paths with the addition of ${POD_ROOT}/Headers/Public like it’s mentioned in the guide) the build still fails on the import <React/RCTPushNotificationManager.h>. I’m not sure where to go from there.

  • I found with some research that you sometimes need to modify the project’s scheme, including React ahead of the actual project as a target and disabling parallel builds, but has anyone needed to do this before and can confirm it’s necessary?

Overall these questions are pretty Xcode/iOS/PushNotificationIOS heavy, but I hope there are enough general detach questions as well to make this relevant. Any help would be greatly appreciated!

CC @ide @firdausious

Hi @mattschwarz -

Expo notifications are supported only in the Expo client when using XDE/exp (not create-react-native-app) and with standalone apps made with exp build. Detached (ExpoKit) and ejected (bare React Native) are not supported.

It’s likely a good idea to write the AppDelegate’s notification-related methods to interact only with your custom push notification code instead of also interacting with Expo’s (though there might be edge cases around things like passing information about the notification to JS. I’m not sure what those would be, just that I’d code more carefully there.)

My general advice would be to set up notification libraries as if you were implementing notifications in Objective-C without React Native. The RN and Expo parts affect mostly the API between JS and native, and communicating with Apple is all straight Objective-C and standard iOS. Notifications are more complicated to set up than other modules, though, so a library written for React Native might not just work with Expo – Expo uses RN but it isn’t RN and you might need to modify some Objective-C to get things working.

@ide can you provide any more info here? I’ve had to detach from Expo due to an Expo.Video bug, so now I’m stuck without push notifications.

react-native-onesignal won’t properly build in my detached iOS project due to .h files not being found. The PushNotificationIOS lib won’t build for similar reasons (as mentioned above by @mattschwarz). So it seems that the only way forward is to either (1) manually implement all native push notification code or (2) get off of Expo completely.

I likely don’t understand the inner workings of ExpoKit in any real depth, but it seems to me that if I manually implement all push notification related native code, then I’d just be replicating PushNotificationIOS, which obviously doesn’t presently work with Expo. So I’m sort of at an impasse here :confused:

Figuring out the .h issue and getting your project to compile is probably the fastest option and it’s probably a typical Xcode configuration issue. If you’re stuck, we’d probably have to look at your project and spend time investigating, which we can’t do for everyone, but you could talk to one of the consultants here Consultants — Expo or talk to us about an enterprise support plan.

1 Like

@mattschwarz were you able to resolve this linking issue? I’m having the same problem
cc @ide

@wrightmk Were you able to figure it out? I’m on the same issue

@sirdevanl Sure was.

Depending on the import thats missing in Xcode will determine which file you’ll want to include in your header search path. In your case <React/RCTPushNotificationManager.h>

  1. cd into your project and make sure you have a podfile (pod install)
  2. You’re going to want to open up your finder then open up project-name/ios/Pods/Headers/Public
  3. Your Xcode wants React/RCTPush… so drag and drop the React folder in 2. ^ into your header search path (since RCTPushNotificationManager.h is listed in here).
  4. You can find your header search path by opening up Xcode and clicking on your project in the top left corner then opening up the Libraries folder and then opening up RCTPushNotification.xcodeproj. Click Build Setting and type header search path in the search bar. Then open it up and drag and drop 3. ^ over.

Hope this helps