The Expo Modules API allows you to "write custom native code to tap into native platform APIs". There are three main APIs:
Native Modules
Android Lifecycle Listeners
iOS AppDelegate Subscribers
Unrelated (but can be packaged together), there are Expo config plugins that extend the app config and allow for mod(ifications)s of parts the Expo build process (eg the Xcode project, plists, gradle files).
plugin/* Config plugin that copies the notification services extension to the generated project, adds the extension to the Xcode project, and updates the Podfile to make the new target depend on the AppcuesNotificationExtension pod.
ios/* iOS AppDelegate subscriber to call Appcues.enableAutomaticPushConfig(). The AppcuesExpoConfig.podspec adds the dependency on the Appcues pod. The subscriber is registered in expo-module.config.json.
android/* This is where an Android lifecycle listener code would go, but we don't actually need that functionality. What we do need here is just need the build.gradle to ensure the Appcues dependency is set, and then the manifest to handle the intent.
Notes
Android alpha version is specified in android/build.gradle
iOS alpha version (well actually a local dependency until I publish it) is specified in plugin/src/withIosAppcuesRichPush.ts where we add the target info to the project Podfile
I haven't verified that the required Android manifest part is rolled up from android/src/main/AndroidManifest.xml.
For the iOS Xcode project modification, there's a helpful example here and a good example for copying files here.
There's no dependency on @appcues/react-native. That package functions as a sibling. Obviously you'd want to use them together to do anything productive, but they are independent.
Expo Overview
The Expo Modules API allows you to "write custom native code to tap into native platform APIs". There are three main APIs:
Unrelated (but can be packaged together), there are Expo config plugins that extend the app config and allow for mod(ifications)s of parts the Expo build process (eg the Xcode project, plists, gradle files).
There's a helpful Expo tutorial, Create a module with a config plugin that while not exactly what we need, show how to combine the concepts.
Implementation Overview
This PR includes a combination of the above:
plugin/*
Config plugin that copies the notification services extension to the generated project, adds the extension to the Xcode project, and updates the Podfile to make the new target depend on theAppcuesNotificationExtension
pod.ios/*
iOS AppDelegate subscriber to callAppcues.enableAutomaticPushConfig()
. TheAppcuesExpoConfig.podspec
adds the dependency on theAppcues
pod. The subscriber is registered inexpo-module.config.json
.android/*
This is where an Android lifecycle listener code would go, but we don't actually need that functionality. What we do need here is just need thebuild.gradle
to ensure the Appcues dependency is set, and then the manifest to handle the intent.Notes
android/build.gradle
plugin/src/withIosAppcuesRichPush.ts
where we add the target info to the project Podfileandroid/src/main/AndroidManifest.xml
.@appcues/react-native
. That package functions as a sibling. Obviously you'd want to use them together to do anything productive, but they are independent.