OneSignal

Integrate the OneSignal platform to display custom local notifications with Notifee.

OneSignal is a platform for sending cloud messages to mobile devices

In their react-native documentation they describe several things you must do, but users here have noticed incompatibilities (and also here) when following the documentation because the One Signal libraries appear to be a bit out of date.

With special thanks to users Ashok Kumar and burhanDebug and zaweisise for helping us figure it out and confirm a solution, this is how to integrate notifee with OneSignal:

  1. Do not use the onesignal gradle plugin (currently step 3.2 in their documentation)
  2. If using a react-native-onesignal version earlier than 4.0.0 - edit node_modules/react-native-onesignal/android/build.gradle:

In the android dependencies modify the api ('com.onesignal:OneSignal:3.15.1') to

api ('com.onesignal:OneSignal:3.15.1') {
  exclude group: 'com.google.android.gms', module: 'play-services-location'
  exclude group: 'com.google.android.gms', module: 'play-services-base'
  exclude group: 'com.google.android.gms', module: 'play-services-ads-identifier'
  exclude group: 'com.google.firebase', module: 'firebase-messaging'
}

We understand that editing files directly in node_modules is unconventional advice, we strongly recommend the use of patch-package in order to manage this change.

patch-package will make a patch for this change that you put in source control, it will reliably install the patch when you install npm packages, and it will give you a friendly warning in case One Signal updates their module.

To use patch-package in this case follow these steps:

  1. Clean out android build items so they do not clutter the patch: cd android && ./gradlew clean && cd ..
  2. Install patch-package according to their docs (mkdir patches and edit package.json to add patch-package to your postinstall)
  3. Create the patch: npx patch-package react-native-onesignal
  4. Add the patch to source control (for example for git git add patches && git commit)