Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial module implementation #1

Merged
merged 5 commits into from
May 8, 2024
Merged

Initial module implementation #1

merged 5 commits into from
May 8, 2024

Conversation

mmaatttt
Copy link
Collaborator

@mmaatttt mmaatttt commented May 3, 2024

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.

@mmaatttt mmaatttt requested a review from iujames May 3, 2024 15:51
Copy link
Contributor

@iujames iujames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing work! few random thoughts as I browsed through it noted

CONTRIBUTING.md Outdated Show resolved Hide resolved
CONTRIBUTING.md Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
apply plugin: 'maven-publish'

group = 'expo.modules.appcuesexpoconfig'
version = '0.1.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious what this version is used for and whether it needs to stay in sync with the overall package version on release... will continue reading

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. I think it's entirely internal (same idea as AppcuesExpoConfig.podspec), so I don't think it matters, but it probably should match other versions, just so it's not confusing?

android/build.gradle Outdated Show resolved Hide resolved
example/App.tsx Outdated Show resolved Hide resolved
ios/AppcuesAppDelegate.swift Show resolved Hide resolved
ios/AppcuesExpoConfig.podspec Outdated Show resolved Hide resolved
plugin/src/withIosAppcuesRichPush.ts Show resolved Hide resolved
@mmaatttt mmaatttt force-pushed the feature/initial-module branch from ff0c3db to cd10de8 Compare May 6, 2024 13:21
@mmaatttt mmaatttt force-pushed the feature/initial-module branch from cd10de8 to 567b929 Compare May 8, 2024 18:20
Comment on lines +73 to +80
// https://github.com/apache/cordova-node-xcode/issues/121
// addTargetDependency misses some dependency links if
// PBXTargetDependency or PBXContainerItemProxy are not present.
const projObjects = xcodeProject.hash.project.objects;
projObjects['PBXTargetDependency'] =
projObjects['PBXTargetDependency'] || {};
projObjects['PBXContainerItemProxy'] =
projObjects['PBXContainerItemProxy'] || {};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this block after encountering issues when testing today.

@mmaatttt mmaatttt merged commit be9e9a6 into main May 8, 2024
1 check passed
@mmaatttt mmaatttt deleted the feature/initial-module branch May 8, 2024 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants