@trycourier/courier-react-native 5.7.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -161,8 +161,8 @@ Starter projects using this SDK.
161
161
  <tbody>
162
162
  <tr width="1000px">
163
163
  <td align="left">
164
- <a href="https://github.com/trycourier/courier-react-native/tree/master/example">
165
- <code>Example</code>
164
+ <a href="https://github.com/trycourier/courier-react-native/tree/master/example-085">
165
+ <code>Example (React Native 0.85+, New Architecture)</code>
166
166
  </a>
167
167
  </td>
168
168
  </tr>
@@ -21,13 +21,16 @@ def isNewArchitectureEnabled() {
21
21
  apply plugin: "com.android.library"
22
22
  apply plugin: "kotlin-android"
23
23
 
24
-
25
24
  def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
26
25
 
27
26
  if (isNewArchitectureEnabled()) {
28
27
  apply plugin: "com.facebook.react"
29
28
  }
30
29
 
30
+ def safeExtGet(prop, fallback) {
31
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
32
+ }
33
+
31
34
  def getExtOrDefault(name) {
32
35
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["CourierReactNative_" + name]
33
36
  }
@@ -61,15 +64,15 @@ android {
61
64
  }
62
65
  }
63
66
 
64
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
67
+ compileSdkVersion safeExtGet("compileSdkVersion", getExtOrIntegerDefault("compileSdkVersion"))
65
68
 
66
69
  buildFeatures {
67
70
  buildConfig true
68
71
  }
69
72
 
70
73
  defaultConfig {
71
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
72
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
74
+ minSdkVersion safeExtGet("minSdkVersion", getExtOrIntegerDefault("minSdkVersion"))
75
+ targetSdkVersion safeExtGet("targetSdkVersion", getExtOrIntegerDefault("targetSdkVersion"))
73
76
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
74
77
  }
75
78
 
@@ -100,19 +103,20 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
100
103
 
101
104
  dependencies {
102
105
 
103
- // For < 0.71, this will be from the local maven repo
104
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
105
106
  //noinspection GradleDynamicVersion
106
- implementation "com.facebook.react:react-android:0.73.7"
107
+ implementation "com.facebook.react:react-android:+"
107
108
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
108
109
 
109
110
  // For converting to json
110
111
  implementation 'com.google.code.gson:gson:2.11.0'
111
112
 
112
113
  // Courier Core SDK
113
- api 'com.github.trycourier:courier-android:5.3.1'
114
+ api 'com.github.trycourier:courier-android:6.0.0'
114
115
  api 'androidx.recyclerview:recyclerview:1.3.2'
115
116
 
117
+ // Firebase Messaging (needed to resolve RemoteMessage from Courier SDK APIs)
118
+ compileOnly 'com.google.firebase:firebase-messaging:23.4.1'
119
+
116
120
  }
117
121
 
118
122
  if (isNewArchitectureEnabled()) {
@@ -1,5 +1,5 @@
1
- CourierReactNative_kotlinVersion=1.7.0
2
- CourierReactNative_minSdkVersion=23
3
- CourierReactNative_targetSdkVersion=31
4
- CourierReactNative_compileSdkVersion=31
5
- CourierReactNative_ndkversion=21.4.7075529
1
+ CourierReactNative_kotlinVersion=1.9.24
2
+ CourierReactNative_minSdkVersion=24
3
+ CourierReactNative_targetSdkVersion=34
4
+ CourierReactNative_compileSdkVersion=34
5
+ CourierReactNative_ndkversion=26.1.10909125
@@ -77,11 +77,7 @@ class CourierClientModule(
77
77
  return@launch
78
78
  }
79
79
 
80
- if (reactActivity == null) {
81
- promise.rejectMissingContext()
82
- return@launch
83
- }
84
-
80
+ val context = reactApplicationContext
85
81
  val courierDevice = device?.let {
86
82
  CourierDevice(
87
83
  appId = it.getString("appId"),
@@ -97,7 +93,7 @@ class CourierClientModule(
97
93
  client.tokens.putUserToken(
98
94
  token = token,
99
95
  provider = provider,
100
- device = courierDevice ?: CourierDevice.current(reactActivity!!)
96
+ device = courierDevice ?: CourierDevice.current(context)
101
97
  )
102
98
  promise.resolve(null)
103
99
  } catch (e: Exception) {
@@ -43,8 +43,8 @@ class CourierPreferencesViewManager : SimpleViewManager<CourierPreferences>() {
43
43
 
44
44
  override fun createViewInstance(reactContext: ThemedReactContext): CourierPreferences {
45
45
  themedReactContext = reactContext
46
- val activity = reactContext.currentActivity as FragmentActivity
47
- return CourierReactNativePreferencesView(activity)
46
+ val context = (reactContext.currentActivity as? FragmentActivity) ?: reactContext
47
+ return CourierReactNativePreferencesView(context)
48
48
  }
49
49
 
50
50
  @ReactProp(name = "onScrollPreferences")
@@ -9,24 +9,20 @@ import com.courier.android.models.CourierTrackingEvent.DELIVERED
9
9
  import com.courier.android.modules.isPushPermissionGranted
10
10
  import com.courier.android.modules.requestNotificationPermission
11
11
  import com.courier.android.utils.error
12
- import com.courier.android.utils.onPushNotificationEvent
13
- import com.courier.android.utils.pushNotification
14
12
  import com.courier.android.utils.trackPushNotificationClick
15
13
  import com.facebook.react.bridge.Promise
16
14
  import com.facebook.react.bridge.ReactApplicationContext
17
15
  import com.facebook.react.bridge.ReactMethod
18
- import com.google.firebase.messaging.RemoteMessage
19
16
  import org.json.JSONObject
20
17
 
21
18
  class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeModule(tag = "System Error", name = "CourierSystemModule", reactContext = reactContext) {
22
19
 
23
20
  init {
24
21
 
25
- // Listen to push notification events
26
22
  Courier.shared.onPushNotificationEvent { event ->
27
23
  when (event.trackingEvent) {
28
- CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.remoteMessage)
29
- DELIVERED -> postPushNotificationJavascriptEvent(CourierEvents.Push.DELIVERED_EVENT, event.remoteMessage)
24
+ CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.data)
25
+ DELIVERED -> postPushNotificationJavascriptEvent(CourierEvents.Push.DELIVERED_EVENT, event.data)
30
26
  else -> Log.w("CourierSystemModule", "Unknown tracking event: ${event.trackingEvent}")
31
27
  }
32
28
  }
@@ -45,29 +41,40 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
45
41
 
46
42
  @ReactMethod
47
43
  fun registerPushNotificationClickedOnKilledState() {
48
- reactActivity?.let { activity ->
49
- checkIntentForPushNotificationClick(activity.intent)
44
+ activity?.let { act ->
45
+ checkIntentForPushNotificationClick(act.intent)
50
46
  }
51
47
  }
52
48
 
53
49
  private fun checkIntentForPushNotificationClick(intent: Intent?) {
54
50
  intent?.trackPushNotificationClick { message ->
55
- postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message)
51
+ postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message.data)
56
52
  }
57
53
  }
58
54
 
59
- private fun postPushNotificationJavascriptEvent(eventName: String, message: RemoteMessage) {
55
+ private fun postPushNotificationJavascriptEvent(eventName: String, data: Map<String, String>) {
56
+ val rawData = data.toMutableMap()
57
+ val payload = mutableMapOf<String, Any?>()
58
+ val baseKeys = listOf("title", "subtitle", "body", "badge", "sound")
59
+ baseKeys.forEach { key ->
60
+ payload[key] = data[key]
61
+ rawData.remove(key)
62
+ }
63
+ for ((key, value) in rawData) {
64
+ payload[key] = value
65
+ }
66
+ payload["raw"] = data
60
67
  reactApplicationContext.sendEvent(
61
68
  eventName = eventName,
62
- value = JSONObject(message.pushNotification).toString()
69
+ value = JSONObject(payload).toString()
63
70
  )
64
71
  }
65
72
 
66
73
  @ReactMethod
67
74
  fun requestNotificationPermission(promise: Promise) {
68
75
 
69
- reactActivity?.let { activity ->
70
- Courier.shared.requestNotificationPermission(activity)
76
+ activity?.let { act ->
77
+ Courier.shared.requestNotificationPermission(act)
71
78
  }
72
79
 
73
80
  promise.resolve("unknown")
@@ -77,9 +84,9 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
77
84
  @ReactMethod
78
85
  fun getNotificationPermissionStatus(promise: Promise) {
79
86
 
80
- reactActivity?.let { context ->
87
+ activity?.let { act ->
81
88
 
82
- val isGranted = Courier.shared.isPushPermissionGranted(context)
89
+ val isGranted = Courier.shared.isPushPermissionGranted(act)
83
90
  val status = if (isGranted) "authorized" else "denied"
84
91
  promise.resolve(status)
85
92
  return
@@ -92,7 +99,6 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
92
99
 
93
100
  @ReactMethod(isBlockingSynchronousMethod = true)
94
101
  fun openSettingsForApp(): String? {
95
- // TODO: Move this to the native package in the future
96
102
  val context = reactApplicationContext
97
103
  try {
98
104
  val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
@@ -1,7 +1,7 @@
1
1
  package com.courierreactnative
2
2
 
3
+ import android.app.Activity
3
4
  import com.courier.android.Courier
4
- import com.facebook.react.ReactActivity
5
5
  import com.facebook.react.bridge.Promise
6
6
  import com.facebook.react.bridge.ReactApplicationContext
7
7
  import com.facebook.react.bridge.ReactContextBaseJavaModule
@@ -10,14 +10,10 @@ abstract class ReactNativeModule(val tag: String, private val name: String, reac
10
10
 
11
11
  override fun getName() = name
12
12
 
13
- val reactActivity: ReactActivity? get() = currentActivity as? ReactActivity
13
+ val activity: Activity? get() = reactApplicationContext.currentActivity
14
14
 
15
15
  init {
16
-
17
- // User Agent is used to ensure we know the SDK
18
- // the requests come from
19
16
  Courier.agent = Utils.COURIER_AGENT
20
-
21
17
  }
22
18
 
23
19
  internal fun Promise.rejectMissingContext() {
@@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
15
15
  import com.google.gson.GsonBuilder
16
16
 
17
17
  internal object Utils {
18
- val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.7.1")
18
+ val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "6.0.0")
19
19
  }
20
20
 
21
21
  internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
@@ -33,7 +33,7 @@ static NSString *const CourierForegroundOptionsDidChangeNotification = @"iosFore
33
33
  if (self) {
34
34
 
35
35
  // Set the user agent
36
- Courier.agent = [CourierAgent reactNativeIOS:@"5.7.1"];
36
+ Courier.agent = [CourierAgent reactNativeIOS:@"6.0.0"];
37
37
 
38
38
  // Register for remote notifications
39
39
  UIApplication *app = [UIApplication sharedApplication];
@@ -14,7 +14,7 @@ internal class CourierReactNativeEventEmitter: RCTEventEmitter {
14
14
 
15
15
  // Set the user agent
16
16
  // Used to know the platform performing requests
17
- Courier.agent = CourierAgent.reactNativeIOS("5.7.1")
17
+ Courier.agent = CourierAgent.reactNativeIOS("6.0.0")
18
18
 
19
19
  }
20
20
 
@@ -10,11 +10,12 @@ class Modules {
10
10
  ios: "- You have run 'pod install'\n",
11
11
  default: ''
12
12
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
13
- static Client = Modules.getNativeModule(_reactNative.NativeModules.CourierClientModule);
14
- static Shared = Modules.getNativeModule(_reactNative.NativeModules.CourierSharedModule);
15
- static System = Modules.getNativeModule(_reactNative.NativeModules.CourierSystemModule);
16
- static getNativeModule(nativeModule) {
17
- return nativeModule ? nativeModule : new Proxy({}, {
13
+ static Client = Modules.getNativeModule('CourierClientModule', _reactNative.NativeModules.CourierClientModule);
14
+ static Shared = Modules.getNativeModule('CourierSharedModule', _reactNative.NativeModules.CourierSharedModule);
15
+ static System = Modules.getNativeModule('CourierSystemModule', _reactNative.NativeModules.CourierSystemModule);
16
+ static getNativeModule(moduleName, bridgeModule) {
17
+ const resolved = (_reactNative.TurboModuleRegistry === null || _reactNative.TurboModuleRegistry === void 0 ? void 0 : _reactNative.TurboModuleRegistry.get(moduleName)) ?? bridgeModule ?? undefined;
18
+ return resolved ? resolved : new Proxy({}, {
18
19
  get() {
19
20
  throw new Error(Modules.LINKING_ERROR);
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","Modules","LINKING_ERROR","Platform","select","ios","default","Client","getNativeModule","NativeModules","CourierClientModule","Shared","CourierSharedModule","System","CourierSystemModule","nativeModule","Proxy","get","Error","getNativeComponent","componentName","UIManager","getViewManagerConfig","requireNativeComponent","exports"],"sourceRoot":"../../src","sources":["Modules.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOO,MAAMC,OAAO,CAAC;EACnB,OAAgBC,aAAa,GAC3B,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;IAAEC,GAAG,EAAE,gCAAgC;IAAEC,OAAO,EAAE;EAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;EAEjC,OAAgBC,MAAM,GAAGN,OAAO,CAACO,eAAe,CAC9CC,0BAAa,CAACC,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGV,OAAO,CAACO,eAAe,CAC9CC,0BAAa,CAACG,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGZ,OAAO,CAACO,eAAe,CAC9CC,0BAAa,CAACK,mBAChB,CAAC;EAED,OAAON,eAAeA,CAAIO,YAA2B,EAAK;IACxD,OAAOA,YAAY,GACfA,YAAY,GACX,IAAIC,KAAK,CACR,CAAC,CAAC,EACF;MACEC,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIC,KAAK,CAACjB,OAAO,CAACC,aAAa,CAAC;MACxC;IACF,CACF,CAAO;EACb;EAEA,OAAOiB,kBAAkBA,CAACC,aAAqB,EAAE;IAC/C,OAAOC,sBAAS,CAACC,oBAAoB,CAACF,aAAa,CAAC,IAAI,IAAI,GACxD,IAAAG,mCAAsB,EAAMH,aAAa,CAAC,GAC1C,MAAM;MACJ,MAAM,IAAIF,KAAK,CAACjB,OAAO,CAACC,aAAa,CAAC;IACxC,CAAC;EACP;AACF;AAACsB,OAAA,CAAAvB,OAAA,GAAAA,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","Modules","LINKING_ERROR","Platform","select","ios","default","Client","getNativeModule","NativeModules","CourierClientModule","Shared","CourierSharedModule","System","CourierSystemModule","moduleName","bridgeModule","resolved","TurboModuleRegistry","get","undefined","Proxy","Error","getNativeComponent","componentName","UIManager","getViewManagerConfig","requireNativeComponent","exports"],"sourceRoot":"../../src","sources":["Modules.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQO,MAAMC,OAAO,CAAC;EACnB,OAAgBC,aAAa,GAC3B,2FAA2F,GAC3FC,qBAAQ,CAACC,MAAM,CAAC;IAAEC,GAAG,EAAE,gCAAgC;IAAEC,OAAO,EAAE;EAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;EAEjC,OAAgBC,MAAM,GAAGN,OAAO,CAACO,eAAe,CAC9C,qBAAqB,EACrBC,0BAAa,CAACC,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGV,OAAO,CAACO,eAAe,CAC9C,qBAAqB,EACrBC,0BAAa,CAACG,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGZ,OAAO,CAACO,eAAe,CAC9C,qBAAqB,EACrBC,0BAAa,CAACK,mBAChB,CAAC;EAED,OAAON,eAAeA,CACpBO,UAAkB,EAClBC,YAA2B,EACxB;IACH,MAAMC,QAAQ,GACZ,CAACC,gCAAmB,aAAnBA,gCAAmB,uBAAnBA,gCAAmB,CAAEC,GAAG,CAACJ,UAAU,CAAC,KACrCC,YAAY,IACZI,SAAS;IACX,OAAOH,QAAQ,GACXA,QAAQ,GACP,IAAII,KAAK,CACR,CAAC,CAAC,EACF;MACEF,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIG,KAAK,CAACrB,OAAO,CAACC,aAAa,CAAC;MACxC;IACF,CACF,CAAO;EACb;EAEA,OAAOqB,kBAAkBA,CAACC,aAAqB,EAAE;IAC/C,OAAOC,sBAAS,CAACC,oBAAoB,CAACF,aAAa,CAAC,IAAI,IAAI,GACxD,IAAAG,mCAAsB,EAAMH,aAAa,CAAC,GAC1C,MAAM;MACJ,MAAM,IAAIF,KAAK,CAACrB,OAAO,CAACC,aAAa,CAAC;IACxC,CAAC;EACP;AACF;AAAC0B,OAAA,CAAA3B,OAAA,GAAAA,OAAA","ignoreList":[]}
@@ -1,14 +1,15 @@
1
- import { NativeModules, Platform, UIManager, requireNativeComponent } from 'react-native';
1
+ import { NativeModules, Platform, UIManager, TurboModuleRegistry, requireNativeComponent } from 'react-native';
2
2
  export class Modules {
3
3
  static LINKING_ERROR = `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
4
4
  ios: "- You have run 'pod install'\n",
5
5
  default: ''
6
6
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
7
- static Client = Modules.getNativeModule(NativeModules.CourierClientModule);
8
- static Shared = Modules.getNativeModule(NativeModules.CourierSharedModule);
9
- static System = Modules.getNativeModule(NativeModules.CourierSystemModule);
10
- static getNativeModule(nativeModule) {
11
- return nativeModule ? nativeModule : new Proxy({}, {
7
+ static Client = Modules.getNativeModule('CourierClientModule', NativeModules.CourierClientModule);
8
+ static Shared = Modules.getNativeModule('CourierSharedModule', NativeModules.CourierSharedModule);
9
+ static System = Modules.getNativeModule('CourierSystemModule', NativeModules.CourierSystemModule);
10
+ static getNativeModule(moduleName, bridgeModule) {
11
+ const resolved = (TurboModuleRegistry === null || TurboModuleRegistry === void 0 ? void 0 : TurboModuleRegistry.get(moduleName)) ?? bridgeModule ?? undefined;
12
+ return resolved ? resolved : new Proxy({}, {
12
13
  get() {
13
14
  throw new Error(Modules.LINKING_ERROR);
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","Platform","UIManager","requireNativeComponent","Modules","LINKING_ERROR","select","ios","default","Client","getNativeModule","CourierClientModule","Shared","CourierSharedModule","System","CourierSystemModule","nativeModule","Proxy","get","Error","getNativeComponent","componentName","getViewManagerConfig"],"sourceRoot":"../../src","sources":["Modules.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,QAAQ,EACRC,SAAS,EACTC,sBAAsB,QACjB,cAAc;AAErB,OAAO,MAAMC,OAAO,CAAC;EACnB,OAAgBC,aAAa,GAC3B,2FAA2F,GAC3FJ,QAAQ,CAACK,MAAM,CAAC;IAAEC,GAAG,EAAE,gCAAgC;IAAEC,OAAO,EAAE;EAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;EAEjC,OAAgBC,MAAM,GAAGL,OAAO,CAACM,eAAe,CAC9CV,aAAa,CAACW,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGR,OAAO,CAACM,eAAe,CAC9CV,aAAa,CAACa,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGV,OAAO,CAACM,eAAe,CAC9CV,aAAa,CAACe,mBAChB,CAAC;EAED,OAAOL,eAAeA,CAAIM,YAA2B,EAAK;IACxD,OAAOA,YAAY,GACfA,YAAY,GACX,IAAIC,KAAK,CACR,CAAC,CAAC,EACF;MACEC,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIC,KAAK,CAACf,OAAO,CAACC,aAAa,CAAC;MACxC;IACF,CACF,CAAO;EACb;EAEA,OAAOe,kBAAkBA,CAACC,aAAqB,EAAE;IAC/C,OAAOnB,SAAS,CAACoB,oBAAoB,CAACD,aAAa,CAAC,IAAI,IAAI,GACxDlB,sBAAsB,CAAMkB,aAAa,CAAC,GAC1C,MAAM;MACJ,MAAM,IAAIF,KAAK,CAACf,OAAO,CAACC,aAAa,CAAC;IACxC,CAAC;EACP;AACF","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","Platform","UIManager","TurboModuleRegistry","requireNativeComponent","Modules","LINKING_ERROR","select","ios","default","Client","getNativeModule","CourierClientModule","Shared","CourierSharedModule","System","CourierSystemModule","moduleName","bridgeModule","resolved","get","undefined","Proxy","Error","getNativeComponent","componentName","getViewManagerConfig"],"sourceRoot":"../../src","sources":["Modules.tsx"],"mappings":"AAAA,SACEA,aAAa,EACbC,QAAQ,EACRC,SAAS,EACTC,mBAAmB,EACnBC,sBAAsB,QACjB,cAAc;AAErB,OAAO,MAAMC,OAAO,CAAC;EACnB,OAAgBC,aAAa,GAC3B,2FAA2F,GAC3FL,QAAQ,CAACM,MAAM,CAAC;IAAEC,GAAG,EAAE,gCAAgC;IAAEC,OAAO,EAAE;EAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;EAEjC,OAAgBC,MAAM,GAAGL,OAAO,CAACM,eAAe,CAC9C,qBAAqB,EACrBX,aAAa,CAACY,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGR,OAAO,CAACM,eAAe,CAC9C,qBAAqB,EACrBX,aAAa,CAACc,mBAChB,CAAC;EACD,OAAgBC,MAAM,GAAGV,OAAO,CAACM,eAAe,CAC9C,qBAAqB,EACrBX,aAAa,CAACgB,mBAChB,CAAC;EAED,OAAOL,eAAeA,CACpBM,UAAkB,EAClBC,YAA2B,EACxB;IACH,MAAMC,QAAQ,GACZ,CAAChB,mBAAmB,aAAnBA,mBAAmB,uBAAnBA,mBAAmB,CAAEiB,GAAG,CAACH,UAAU,CAAC,KACrCC,YAAY,IACZG,SAAS;IACX,OAAOF,QAAQ,GACXA,QAAQ,GACP,IAAIG,KAAK,CACR,CAAC,CAAC,EACF;MACEF,GAAGA,CAAA,EAAG;QACJ,MAAM,IAAIG,KAAK,CAAClB,OAAO,CAACC,aAAa,CAAC;MACxC;IACF,CACF,CAAO;EACb;EAEA,OAAOkB,kBAAkBA,CAACC,aAAqB,EAAE;IAC/C,OAAOvB,SAAS,CAACwB,oBAAoB,CAACD,aAAa,CAAC,IAAI,IAAI,GACxDrB,sBAAsB,CAAMqB,aAAa,CAAC,GAC1C,MAAM;MACJ,MAAM,IAAIF,KAAK,CAAClB,OAAO,CAACC,aAAa,CAAC;IACxC,CAAC;EACP;AACF","ignoreList":[]}
@@ -3,7 +3,7 @@ export declare class Modules {
3
3
  static readonly Client: any;
4
4
  static readonly Shared: any;
5
5
  static readonly System: any;
6
- static getNativeModule<T>(nativeModule: T | undefined): T;
6
+ static getNativeModule<T>(moduleName: string, bridgeModule: T | undefined): T;
7
7
  static getNativeComponent(componentName: string): import("react-native").HostComponent<any> | (() => never);
8
8
  }
9
9
  //# sourceMappingURL=Modules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modules.d.ts","sourceRoot":"","sources":["../../../src/Modules.tsx"],"names":[],"mappings":"AAOA,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ,CAAC,aAAa,SAIK;IAElC,MAAM,CAAC,QAAQ,CAAC,MAAM,MAEpB;IACF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAEpB;IACF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAEpB;IAEF,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC;IAazD,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM;CAOhD"}
1
+ {"version":3,"file":"Modules.d.ts","sourceRoot":"","sources":["../../../src/Modules.tsx"],"names":[],"mappings":"AAQA,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ,CAAC,aAAa,SAIK;IAElC,MAAM,CAAC,QAAQ,CAAC,MAAM,MAGpB;IACF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAGpB;IACF,MAAM,CAAC,QAAQ,CAAC,MAAM,MAGpB;IAEF,MAAM,CAAC,eAAe,CAAC,CAAC,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,CAAC,GAAG,SAAS,GAC1B,CAAC;IAiBJ,MAAM,CAAC,kBAAkB,CAAC,aAAa,EAAE,MAAM;CAOhD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/courier-react-native",
3
- "version": "5.7.1",
3
+ "version": "6.0.0",
4
4
  "description": "Inbox, Push Notifications, and Preferences for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -14,7 +14,8 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "*.podspec",
17
- "!lib/typescript/example",
17
+ "!lib/typescript/example-073",
18
+ "!lib/typescript/example-085",
18
19
  "!ios/build",
19
20
  "!android/build",
20
21
  "!android/gradle",
@@ -32,11 +33,12 @@
32
33
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
34
  "prepack": "bob build",
34
35
  "release": "release-it",
35
- "example": "yarn --cwd example",
36
- "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
37
- "build:ios": "cd example/ios && xcodebuild -workspace CourierReactNativeExample.xcworkspace -scheme CourierReactNativeExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
36
+ "example": "yarn --cwd example-085",
37
+ "example-073": "yarn --cwd example-073",
38
+ "build:android": "cd example-085/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
39
+ "build:ios": "cd example-085/ios && xcodebuild -workspace CourierReactNativeExample.xcworkspace -scheme CourierReactNativeExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
38
40
  "bootstrap": "yarn example && yarn install && yarn example pods",
39
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build",
41
+ "clean": "del-cli android/build example-085/android/build example-085/android/app/build example-085/ios/build",
40
42
  "linkPackage": "yarn link && yarn example link @trycourier/courier-react-native && yarn example setupEnv",
41
43
  "setup": "sh setup.sh"
42
44
  },
@@ -96,7 +98,9 @@
96
98
  "jest": {
97
99
  "preset": "react-native",
98
100
  "modulePathIgnorePatterns": [
99
- "<rootDir>/example/node_modules",
101
+ "<rootDir>/example-085/node_modules",
102
+ "<rootDir>/example-073/node_modules",
103
+ "<rootDir>/example-expo-55/node_modules",
100
104
  "<rootDir>/lib/"
101
105
  ]
102
106
  },
@@ -144,7 +148,8 @@
144
148
  },
145
149
  "eslintIgnore": [
146
150
  "node_modules/",
147
- "lib/"
151
+ "lib/",
152
+ "example-expo-55/"
148
153
  ],
149
154
  "prettier": {
150
155
  "quoteProps": "consistent",
package/src/Modules.tsx CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  NativeModules,
3
3
  Platform,
4
4
  UIManager,
5
+ TurboModuleRegistry,
5
6
  requireNativeComponent,
6
7
  } from 'react-native';
7
8
 
@@ -13,18 +14,28 @@ export class Modules {
13
14
  '- You are not using Expo Go\n';
14
15
 
15
16
  static readonly Client = Modules.getNativeModule(
17
+ 'CourierClientModule',
16
18
  NativeModules.CourierClientModule
17
19
  );
18
20
  static readonly Shared = Modules.getNativeModule(
21
+ 'CourierSharedModule',
19
22
  NativeModules.CourierSharedModule
20
23
  );
21
24
  static readonly System = Modules.getNativeModule(
25
+ 'CourierSystemModule',
22
26
  NativeModules.CourierSystemModule
23
27
  );
24
28
 
25
- static getNativeModule<T>(nativeModule: T | undefined): T {
26
- return nativeModule
27
- ? nativeModule
29
+ static getNativeModule<T>(
30
+ moduleName: string,
31
+ bridgeModule: T | undefined
32
+ ): T {
33
+ const resolved =
34
+ (TurboModuleRegistry?.get(moduleName) as T | null) ??
35
+ bridgeModule ??
36
+ undefined;
37
+ return resolved
38
+ ? resolved
28
39
  : (new Proxy(
29
40
  {},
30
41
  {