-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
636 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @generated by expo-module-scripts | ||
module.exports = require('expo-module-scripts/eslintrc.base.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# @config-plugins/react-native-appboy-sdk | ||
|
||
Expo Config Plugin to auto configure [`react-native-appboy-sdk`](https://www.npmjs.com/package/react-native-appboy-sdk) when the native code is generated (`expo prebuild`). | ||
|
||
## Expo installation | ||
|
||
> Tested against Expo SDK 42 | ||
This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/). | ||
|
||
- First install the package with yarn, npm, or [`expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install). | ||
|
||
```sh | ||
expo install react-native-appboy-sdk @config-plugins/react-native-appboy-sdk | ||
``` | ||
|
||
After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`: | ||
|
||
```json | ||
{ | ||
"expo": { | ||
"plugins": ["@config-plugins/react-native-appboy-sdk"] | ||
} | ||
} | ||
``` | ||
|
||
Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide. | ||
|
||
## API | ||
|
||
The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used. | ||
|
||
- `foobar` (_boolean_): Does XYZ. Default `false`. | ||
|
||
#### Example | ||
|
||
```json | ||
{ | ||
"expo": { | ||
"plugins": [ | ||
[ | ||
"@config-plugins/react-native-appboy-sdk", | ||
{ | ||
// props ... | ||
} | ||
] | ||
] | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Gradle files | ||
.gradle/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
group = 'host.exp.exponent' | ||
version = '0.0.1' | ||
|
||
buildscript { | ||
// Simple helper that allows the root project to override versions declared by this library. | ||
ext.safeExtGet = { prop, fallback -> | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}") | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet("compileSdkVersion", 30) | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet("minSdkVersion", 21) | ||
targetSdkVersion safeExtGet("targetSdkVersion", 30) | ||
versionCode 1 | ||
versionName '1.1.0' | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':expo-modules-core') | ||
implementation project(':react-native-appboy-sdk') | ||
|
||
//noinspection GradleDynamicVersion | ||
implementation 'com.facebook.react:react-native:+' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}" | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/react-native-appboy-sdk/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<manifest package="expo.modules.adapters.braze"> | ||
<service | ||
android:name="com.braze.push.BrazeFirebaseMessagingService" | ||
android:exported="false"> | ||
<intent-filter> | ||
<action android:name="com.google.firebase.MESSAGING_EVENT" /> | ||
</intent-filter> | ||
</service> | ||
</manifest> |
15 changes: 15 additions & 0 deletions
15
...dk/android/src/main/java/expo/modules/adapters/braze/BrazeApplicationLifecycleListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package expo.modules.adapters.braze | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import expo.modules.core.interfaces.ApplicationLifecycleListener | ||
import com.appboy.AppboyLifecycleCallbackListener | ||
|
||
class BrazeApplicationLifecycleListener(context: Context?) : ApplicationLifecycleListener { | ||
var context = context | ||
|
||
override fun onCreate(application: Application) { | ||
super.onCreate(application) | ||
application.registerActivityLifecycleCallbacks(AppboyLifecycleCallbackListener()) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...react-native-appboy-sdk/android/src/main/java/expo/modules/adapters/braze/BrazePackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package expo.modules.adapters.braze | ||
|
||
import android.content.Context | ||
import expo.modules.core.interfaces.ApplicationLifecycleListener | ||
import expo.modules.core.interfaces.Package | ||
import expo.modules.core.interfaces.ReactActivityLifecycleListener | ||
|
||
class BrazePackage : Package { | ||
override fun createApplicationLifecycleListeners(context: Context?): List<ApplicationLifecycleListener> { | ||
return listOf(BrazeApplicationLifecycleListener(context)) | ||
} | ||
override fun createReactActivityLifecycleListeners(activityContext: Context): List<ReactActivityLifecycleListener> { | ||
return listOf(BrazeReactActivityLifecycleListener(activityContext)) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../android/src/main/java/expo/modules/adapters/braze/BrazeReactActivityLifecycleListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package expo.modules.adapters.braze | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import expo.modules.core.interfaces.ReactActivityLifecycleListener | ||
|
||
|
||
class BrazeReactActivityLifecycleListener(activityContext: Context) : ReactActivityLifecycleListener { | ||
private var activity: Activity? = null | ||
override fun onCreate(activity: Activity, savedInstanceState: Bundle?) { | ||
this.activity = activity | ||
} | ||
|
||
override fun onNewIntent(intent: Intent?): Boolean { | ||
var result = super.onNewIntent(intent) | ||
activity?.intent = intent | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require("./build/withReactNativeAppboySdk"); |
9 changes: 9 additions & 0 deletions
9
packages/react-native-appboy-sdk/build/withReactNativeAppboySdk.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
packages/react-native-appboy-sdk/build/withReactNativeAppboySdk.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"platforms": [ | ||
"android", | ||
"ios" | ||
], | ||
"ios": { | ||
"appDelegateSubscribers": ["BrazeAppDelegate"] | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/react-native-appboy-sdk/ios/ExpoAdapterBraze.podspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'json' | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json'))) | ||
|
||
Pod::Spec.new do |s| | ||
s.name = 'ExpoAdapterBraze' | ||
s.version = package['version'] | ||
s.summary = package['description'] | ||
s.description = package['description'] | ||
s.license = package['license'] | ||
s.author = package['author'] | ||
s.homepage = package['homepage'] | ||
s.platform = :ios, '12.0' | ||
s.swift_version = '5.4' | ||
s.source = { git: 'https://github.com/expo/config-plugins.git' } | ||
s.static_framework = true | ||
|
||
s.dependency 'ExpoModulesCore' | ||
s.dependency 'React-Core' | ||
s.dependency 'react-native-appboy-sdk' | ||
|
||
# Swift/Objective-C compatibility | ||
s.pod_target_xcconfig = { | ||
'DEFINES_MODULE' => 'YES' | ||
} | ||
|
||
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0') | ||
s.source_files = "#{s.name}/**/*.h" | ||
s.vendored_frameworks = "#{s.name}.xcframework" | ||
else | ||
s.source_files = "#{s.name}/**/*.{h,m,swift}" | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
packages/react-native-appboy-sdk/ios/ExpoAdapterBraze/BrazeAppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Appboy_iOS_SDK | ||
import ExpoModulesCore | ||
import SystemConfiguration | ||
|
||
public class BrazeAppDelegate: ExpoAppDelegateSubscriber { | ||
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | ||
let braze = Bundle.main.object(forInfoDictionaryKey: "Braze") | ||
Appboy.start(withApiKey: braze.ApiKey, in:application, withLaunchOptions:launchOptions) | ||
return true | ||
} | ||
|
||
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { | ||
Appboy.sharedInstance()?.registerDeviceToken(deviceToken) | ||
} | ||
|
||
public func application( | ||
_ application: UIApplication, | ||
didReceiveRemoteNotification userInfo: [AnyHashable: Any], | ||
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void | ||
) { | ||
Appboy.sharedInstance()?.register(application, | ||
didReceiveRemoteNotification: userInfo, | ||
fetchCompletionHandler: completionHandler) | ||
} | ||
|
||
// public func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { | ||
// return false | ||
// } | ||
|
||
// public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { | ||
// return false | ||
// } | ||
} |
Oops, something went wrong.