@trycourier/courier-react-native 5.8.0 → 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.
@@ -111,9 +111,12 @@ dependencies {
111
111
  implementation 'com.google.code.gson:gson:2.11.0'
112
112
 
113
113
  // Courier Core SDK
114
- api 'com.github.trycourier:courier-android:5.3.1'
114
+ api 'com.github.trycourier:courier-android:6.0.0'
115
115
  api 'androidx.recyclerview:recyclerview:1.3.2'
116
116
 
117
+ // Firebase Messaging (needed to resolve RemoteMessage from Courier SDK APIs)
118
+ compileOnly 'com.google.firebase:firebase-messaging:23.4.1'
119
+
117
120
  }
118
121
 
119
122
  if (isNewArchitectureEnabled()) {
@@ -9,13 +9,10 @@ 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) {
@@ -24,8 +21,8 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
24
21
 
25
22
  Courier.shared.onPushNotificationEvent { event ->
26
23
  when (event.trackingEvent) {
27
- CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.remoteMessage)
28
- 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)
29
26
  else -> Log.w("CourierSystemModule", "Unknown tracking event: ${event.trackingEvent}")
30
27
  }
31
28
  }
@@ -51,14 +48,25 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
51
48
 
52
49
  private fun checkIntentForPushNotificationClick(intent: Intent?) {
53
50
  intent?.trackPushNotificationClick { message ->
54
- postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message)
51
+ postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message.data)
55
52
  }
56
53
  }
57
54
 
58
- 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
59
67
  reactApplicationContext.sendEvent(
60
68
  eventName = eventName,
61
- value = JSONObject(message.pushNotification).toString()
69
+ value = JSONObject(payload).toString()
62
70
  )
63
71
  }
64
72
 
@@ -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.8.0")
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.8.0"];
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.8.0")
17
+ Courier.agent = CourierAgent.reactNativeIOS("6.0.0")
18
18
 
19
19
  }
20
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trycourier/courier-react-native",
3
- "version": "5.8.0",
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",