Skip to content

Commit d4841f6

Browse files
mikemillacursoragentcourier-android-automation[bot]
authored
feat: Android SDK v6 migration + inbox background color theme props (#53)
* fix: android build for SDK v6 migration - Update CourierSystemModule and ExampleService for SDK v6 API changes - Fix Android Studio jlink failure on Apple Silicon by setting Corretto 17 as Gradle JDK - Upgrade AGP to 8.1.1 and Gradle to 8.3 for compatibility - Update push notification documentation Co-authored-by: Cursor <cursoragent@cursor.com> * docs(example): clarify FCM service integration in ExampleService Document Courier SDK hooks and demo notification handling in the Android example FirebaseMessagingService. Co-authored-by: Cursor <cursoragent@cursor.com> * chore: bump package and native agent version to 6.0.0 Align npm version and iOS/Android Courier agent strings with the v6 SDK migration. Co-authored-by: Cursor <cursoragent@cursor.com> * Bump courier-android to 6.0.1 * feat: add inbox background color theme props and modernize example app - Add listItemBackgroundColor and tabBackgroundColor to CourierInboxTheme (TS, iOS, Android) - Wire backgroundColor into iOS SDK theme constructor, remove wrapper-view workaround - Bump Courier_iOS to 5.8.3, courier-android to 6.0.1 - Delete legacy example-073 project and scrub all references - Add Branded inbox tab to example-085, separate brand theme from styled theme - Update build_demo_app.sh with gum chooser, build number bumping, and signing Co-authored-by: Cursor <cursoragent@cursor.com> * fix: add missing iPad app icons to example-085 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: courier-android-automation[bot] <courier-android-automation[bot]@users.noreply.github.com>
1 parent 89c69a1 commit d4841f6

163 files changed

Lines changed: 257 additions & 34460 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Example
22
example-085/src/Env.tsx
33
example-085/android/app/release/
4-
example-073/src/Env.tsx
5-
example-073/android/app/release/
64
example-expo-55/src/Env.tsx
75
example-expo-55/android/app/release/
86

@@ -53,17 +51,14 @@ android.iml
5351
# Cocoapods
5452
#
5553
example-085/ios/Pods
56-
example-073/ios/Pods
5754
example-expo-55/ios/Pods
5855

5956
# Local Xcode env (machine-specific node path)
6057
example-085/ios/.xcode.env.local
61-
example-073/ios/.xcode.env.local
6258
example-expo-55/ios/.xcode.env.local
6359

6460
# Ruby
6561
example-085/vendor/
66-
example-073/vendor/
6762
example-expo-55/vendor/
6863

6964
# node.js

.vscode/launch.json

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"name": "Bump Version",
66
"type": "node-terminal",
77
"request": "launch",
8-
"command": "sh scripts/bump_version.sh; exit",
8+
"command": "sh scripts/bump_version.sh",
99
"cwd": "${workspaceFolder}"
1010
},
1111
{
1212
"name": "Build Demo App",
1313
"type": "node-terminal",
1414
"request": "launch",
15-
"command": "sh scripts/build_demo_app.sh; exit",
15+
"command": "sh scripts/build_demo_app.sh",
1616
"cwd": "${workspaceFolder}"
1717
},
1818
{
@@ -43,34 +43,6 @@
4343
"command": "cd example-085 && npx react-native run-android --active-arch-only",
4444
"cwd": "${workspaceFolder}"
4545
},
46-
{
47-
"name": "073 – Run iOS (Simulator)",
48-
"type": "node-terminal",
49-
"request": "launch",
50-
"command": "cd example-073 && npx react-native run-ios",
51-
"cwd": "${workspaceFolder}"
52-
},
53-
{
54-
"name": "073 – Run iOS (Device)",
55-
"type": "node-terminal",
56-
"request": "launch",
57-
"command": "cd example-073 && npx react-native run-ios --device",
58-
"cwd": "${workspaceFolder}"
59-
},
60-
{
61-
"name": "073 – Run Android (Emulator)",
62-
"type": "node-terminal",
63-
"request": "launch",
64-
"command": "cd example-073 && npx react-native run-android",
65-
"cwd": "${workspaceFolder}"
66-
},
67-
{
68-
"name": "073 – Run Android (Device)",
69-
"type": "node-terminal",
70-
"request": "launch",
71-
"command": "cd example-073 && npx react-native run-android --active-arch-only",
72-
"cwd": "${workspaceFolder}"
73-
},
7446
{
7547
"name": "Expo 55 – Run iOS (Simulator)",
7648
"type": "node-terminal",

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
From here, you are all set to start working on the package! 🙌
1010

1111
> The repository has two example apps:
12-
> - `example-085/`fresh React Native **0.85.3** scaffold with the New Architecture on. This is the canonical example referenced by all repo scripts (`yarn example`, CI, etc.).
13-
> - `example-073/`the legacy RN 0.73.7 example kept for historical reference. Most repo automation no longer targets it.
12+
> - `example-085/` — React Native **0.85.3** scaffold with the New Architecture on. This is the canonical example referenced by all repo scripts (`yarn example`, CI, etc.).
13+
> - `example-expo-55/`Expo SDK 55 example for testing the Expo plugin.
1414
1515
## Testing & Debugging
1616

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ dependencies {
111111
implementation 'com.google.code.gson:gson:2.11.0'
112112

113113
// Courier Core SDK
114-
api 'com.github.trycourier:courier-android:6.0.0'
114+
api 'com.github.trycourier:courier-android:6.0.1'
115115
api 'androidx.recyclerview:recyclerview:1.3.2'
116116

117117
// Firebase Messaging (needed to resolve RemoteMessage from Courier SDK APIs)

android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
120120

121121
val brandId = getString("brandId")
122122
val backgroundColor = getString("backgroundColor")
123+
val listItemBackgroundColor = getString("listItemBackgroundColor")
124+
val tabBackgroundColor = getString("tabBackgroundColor")
123125

124126
val tabIndicatorColor = getString("tabIndicatorColor")
125127
val tabStyle = getMap("tabStyle")
@@ -141,6 +143,8 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
141143
return CourierInboxTheme(
142144
brandId = brandId,
143145
backgroundColor = backgroundColor?.toColor(),
146+
listItemBackgroundColor = listItemBackgroundColor?.toColor(),
147+
tabBackgroundColor = tabBackgroundColor?.toColor(),
144148
tabIndicatorColor = tabIndicatorColor?.toColor(),
145149
tabStyle = tabStyle?.toTabStyle(context) ?: CourierStyles.Inbox.TabStyle(
146150
selected = CourierStyles.Inbox.TabItemStyle(

android/src/main/java/com/courierreactnative/CourierReactNativeActivity.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@ open class CourierReactNativeActivity : ReactActivity() {
1010

1111
override fun onCreate(savedInstanceState: Bundle?) {
1212

13-
// Update the user agent
1413
Courier.agent = Utils.COURIER_AGENT
15-
16-
// Starts the Courier SDK
17-
// Used to ensure shared preferences works properly
1814
Courier.initialize(this)
1915

2016
super.onCreate(savedInstanceState)
2117

22-
// See if there is a pending click event
2318
checkIntentForPushNotificationClick(intent)
2419

2520
}
@@ -30,6 +25,9 @@ open class CourierReactNativeActivity : ReactActivity() {
3025
}
3126

3227
private fun checkIntentForPushNotificationClick(intent: Intent?) {
28+
// The Courier SDK broadcasts a CLICKED event via Courier.onPushNotificationEvent
29+
// which is observed in CourierSystemModule. No need to reach into the React
30+
// context here, which would crash on Bridgeless / cold start.
3331
intent?.trackPushNotificationClick {}
3432
}
3533

android/src/main/java/com/courierreactnative/CourierSystemModule.kt

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.courierreactnative
22

33
import android.content.Intent
44
import android.provider.Settings
5-
import android.util.Log
65
import com.courier.android.Courier
76
import com.courier.android.models.CourierTrackingEvent.CLICKED
87
import com.courier.android.models.CourierTrackingEvent.DELIVERED
@@ -17,13 +16,15 @@ import org.json.JSONObject
1716

1817
class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeModule(tag = "System Error", name = "CourierSystemModule", reactContext = reactContext) {
1918

19+
private var lastClickedPushNotification: String? = null
20+
2021
init {
2122

22-
Courier.shared.onPushNotificationEvent { event ->
23+
Courier.onPushNotificationEvent { event ->
2324
when (event.trackingEvent) {
24-
CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.data)
2525
DELIVERED -> postPushNotificationJavascriptEvent(CourierEvents.Push.DELIVERED_EVENT, event.data)
26-
else -> Log.w("CourierSystemModule", "Unknown tracking event: ${event.trackingEvent}")
26+
CLICKED -> postPushNotificationClickedEvent(event.data)
27+
else -> {}
2728
}
2829
}
2930

@@ -41,18 +42,39 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
4142

4243
@ReactMethod
4344
fun registerPushNotificationClickedOnKilledState() {
44-
activity?.let { act ->
45-
checkIntentForPushNotificationClick(act.intent)
45+
lastClickedPushNotification?.let { payload ->
46+
reactApplicationContext.sendEvent(
47+
eventName = CourierEvents.Push.CLICKED_EVENT,
48+
value = payload
49+
)
50+
lastClickedPushNotification = null
4651
}
4752
}
4853

49-
private fun checkIntentForPushNotificationClick(intent: Intent?) {
54+
fun checkIntentForPushNotificationClick(intent: Intent?) {
5055
intent?.trackPushNotificationClick { message ->
51-
postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message.data)
56+
postPushNotificationClickedEvent(message.data)
5257
}
5358
}
5459

60+
private fun postPushNotificationClickedEvent(data: Map<String, String>) {
61+
val payload = buildPushPayload(data)
62+
lastClickedPushNotification = payload
63+
reactApplicationContext.sendEvent(
64+
eventName = CourierEvents.Push.CLICKED_EVENT,
65+
value = payload
66+
)
67+
}
68+
5569
private fun postPushNotificationJavascriptEvent(eventName: String, data: Map<String, String>) {
70+
val payload = buildPushPayload(data)
71+
reactApplicationContext.sendEvent(
72+
eventName = eventName,
73+
value = payload
74+
)
75+
}
76+
77+
private fun buildPushPayload(data: Map<String, String>): String {
5678
val rawData = data.toMutableMap()
5779
val payload = mutableMapOf<String, Any?>()
5880
val baseKeys = listOf("title", "subtitle", "body", "badge", "sound")
@@ -64,10 +86,7 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
6486
payload[key] = value
6587
}
6688
payload["raw"] = data
67-
reactApplicationContext.sendEvent(
68-
eventName = eventName,
69-
value = JSONObject(payload).toString()
70-
)
89+
return JSONObject(payload).toString()
7190
}
7291

7392
@ReactMethod

android/src/main/java/com/courierreactnative/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
1515
import com.google.gson.GsonBuilder
1616

1717
internal object Utils {
18-
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "6.0.0")
18+
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "6.0.1")
1919
}
2020

2121
internal fun ReactContext.sendEvent(eventName: String, value: Any?) {

courier-react-native.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.source_files = "ios/**/*.{h,m,mm,swift}"
1818

1919
# Courier Core Dependency
20-
s.dependency "Courier_iOS", "5.8.1"
20+
s.dependency "Courier_iOS", "5.8.3"
2121

2222
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
2323
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.

example-073/.bundle/config

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)