Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Example
example-085/src/Env.tsx
example-085/android/app/release/
example-073/src/Env.tsx
example-073/android/app/release/
example-expo-55/src/Env.tsx
example-expo-55/android/app/release/

Expand Down Expand Up @@ -53,17 +51,14 @@ android.iml
# Cocoapods
#
example-085/ios/Pods
example-073/ios/Pods
example-expo-55/ios/Pods

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

# Ruby
example-085/vendor/
example-073/vendor/
example-expo-55/vendor/

# node.js
Expand Down
32 changes: 2 additions & 30 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"name": "Bump Version",
"type": "node-terminal",
"request": "launch",
"command": "sh scripts/bump_version.sh; exit",
"command": "sh scripts/bump_version.sh",
"cwd": "${workspaceFolder}"
},
{
"name": "Build Demo App",
"type": "node-terminal",
"request": "launch",
"command": "sh scripts/build_demo_app.sh; exit",
"command": "sh scripts/build_demo_app.sh",
"cwd": "${workspaceFolder}"
},
{
Expand Down Expand Up @@ -43,34 +43,6 @@
"command": "cd example-085 && npx react-native run-android --active-arch-only",
"cwd": "${workspaceFolder}"
},
{
"name": "073 – Run iOS (Simulator)",
"type": "node-terminal",
"request": "launch",
"command": "cd example-073 && npx react-native run-ios",
"cwd": "${workspaceFolder}"
},
{
"name": "073 – Run iOS (Device)",
"type": "node-terminal",
"request": "launch",
"command": "cd example-073 && npx react-native run-ios --device",
"cwd": "${workspaceFolder}"
},
{
"name": "073 – Run Android (Emulator)",
"type": "node-terminal",
"request": "launch",
"command": "cd example-073 && npx react-native run-android",
"cwd": "${workspaceFolder}"
},
{
"name": "073 – Run Android (Device)",
"type": "node-terminal",
"request": "launch",
"command": "cd example-073 && npx react-native run-android --active-arch-only",
"cwd": "${workspaceFolder}"
},
{
"name": "Expo 55 – Run iOS (Simulator)",
"type": "node-terminal",
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
From here, you are all set to start working on the package! 🙌

> The repository has two example apps:
> - `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.).
> - `example-073/` — the legacy RN 0.73.7 example kept for historical reference. Most repo automation no longer targets it.
> - `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.).
> - `example-expo-55/` — Expo SDK 55 example for testing the Expo plugin.

## Testing & Debugging

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.11.0'

// Courier Core SDK
api 'com.github.trycourier:courier-android:6.0.0'
api 'com.github.trycourier:courier-android:6.0.1'
api 'androidx.recyclerview:recyclerview:1.3.2'

// Firebase Messaging (needed to resolve RemoteMessage from Courier SDK APIs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {

val brandId = getString("brandId")
val backgroundColor = getString("backgroundColor")
val listItemBackgroundColor = getString("listItemBackgroundColor")
val tabBackgroundColor = getString("tabBackgroundColor")

val tabIndicatorColor = getString("tabIndicatorColor")
val tabStyle = getMap("tabStyle")
Expand All @@ -141,6 +143,8 @@ class CourierInboxViewManager : SimpleViewManager<CourierInbox>() {
return CourierInboxTheme(
brandId = brandId,
backgroundColor = backgroundColor?.toColor(),
listItemBackgroundColor = listItemBackgroundColor?.toColor(),
tabBackgroundColor = tabBackgroundColor?.toColor(),
tabIndicatorColor = tabIndicatorColor?.toColor(),
tabStyle = tabStyle?.toTabStyle(context) ?: CourierStyles.Inbox.TabStyle(
selected = CourierStyles.Inbox.TabItemStyle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ open class CourierReactNativeActivity : ReactActivity() {

override fun onCreate(savedInstanceState: Bundle?) {

// Update the user agent
Courier.agent = Utils.COURIER_AGENT

// Starts the Courier SDK
// Used to ensure shared preferences works properly
Courier.initialize(this)

super.onCreate(savedInstanceState)

// See if there is a pending click event
checkIntentForPushNotificationClick(intent)

}
Expand All @@ -30,6 +25,9 @@ open class CourierReactNativeActivity : ReactActivity() {
}

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

Expand Down
43 changes: 31 additions & 12 deletions android/src/main/java/com/courierreactnative/CourierSystemModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.courierreactnative

import android.content.Intent
import android.provider.Settings
import android.util.Log
import com.courier.android.Courier
import com.courier.android.models.CourierTrackingEvent.CLICKED
import com.courier.android.models.CourierTrackingEvent.DELIVERED
Expand All @@ -17,13 +16,15 @@ import org.json.JSONObject

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

private var lastClickedPushNotification: String? = null

init {

Courier.shared.onPushNotificationEvent { event ->
Courier.onPushNotificationEvent { event ->
when (event.trackingEvent) {
CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.data)
DELIVERED -> postPushNotificationJavascriptEvent(CourierEvents.Push.DELIVERED_EVENT, event.data)
else -> Log.w("CourierSystemModule", "Unknown tracking event: ${event.trackingEvent}")
CLICKED -> postPushNotificationClickedEvent(event.data)
else -> {}
}
}

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

@ReactMethod
fun registerPushNotificationClickedOnKilledState() {
activity?.let { act ->
checkIntentForPushNotificationClick(act.intent)
lastClickedPushNotification?.let { payload ->
reactApplicationContext.sendEvent(
eventName = CourierEvents.Push.CLICKED_EVENT,
value = payload
)
lastClickedPushNotification = null
}
}

private fun checkIntentForPushNotificationClick(intent: Intent?) {
fun checkIntentForPushNotificationClick(intent: Intent?) {
intent?.trackPushNotificationClick { message ->
postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, message.data)
postPushNotificationClickedEvent(message.data)
}
}

private fun postPushNotificationClickedEvent(data: Map<String, String>) {
val payload = buildPushPayload(data)
lastClickedPushNotification = payload
reactApplicationContext.sendEvent(
eventName = CourierEvents.Push.CLICKED_EVENT,
value = payload
)
}

private fun postPushNotificationJavascriptEvent(eventName: String, data: Map<String, String>) {
val payload = buildPushPayload(data)
reactApplicationContext.sendEvent(
eventName = eventName,
value = payload
)
}

private fun buildPushPayload(data: Map<String, String>): String {
val rawData = data.toMutableMap()
val payload = mutableMapOf<String, Any?>()
val baseKeys = listOf("title", "subtitle", "body", "badge", "sound")
Expand All @@ -64,10 +86,7 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
payload[key] = value
}
payload["raw"] = data
reactApplicationContext.sendEvent(
eventName = eventName,
value = JSONObject(payload).toString()
)
return JSONObject(payload).toString()
}

@ReactMethod
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/java/com/courierreactnative/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
import com.google.gson.GsonBuilder

internal object Utils {
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "6.0.0")
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "6.0.1")
}

internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
Expand Down
2 changes: 1 addition & 1 deletion courier-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,swift}"

# Courier Core Dependency
s.dependency "Courier_iOS", "5.8.1"
s.dependency "Courier_iOS", "5.8.3"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down
2 changes: 0 additions & 2 deletions example-073/.bundle/config

This file was deleted.

1 change: 0 additions & 1 deletion example-073/.watchmanconfig

This file was deleted.

6 changes: 0 additions & 6 deletions example-073/Gemfile

This file was deleted.

117 changes: 0 additions & 117 deletions example-073/Gemfile.lock

This file was deleted.

Loading
Loading