appcues / appcues-expo-module

The Appcues Expo Module
MIT License
1 stars 0 forks source link

Initial module implementation #1

Closed mmaatttt closed 6 months ago

mmaatttt commented 6 months ago

Expo Overview

The Expo Modules API allows you to "write custom native code to tap into native platform APIs". There are three main APIs:

  1. Native Modules
  2. Android Lifecycle Listeners
  3. 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).

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:

  1. 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.
  2. 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.
  3. 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

  1. Android alpha version is specified in android/build.gradle
  2. 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
  3. I haven't verified that the required Android manifest part is rolled up from android/src/main/AndroidManifest.xml.
  4. For the iOS Xcode project modification, there's a helpful example here and a good example for copying files here.
  5. 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.