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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changes
- Upgrade Android SDK dependency to v2.14.5
- Upgrade iOS SDK dependency to v2.14.5


## [2.14.5] - 2025-11-21

### Changes
Expand Down
4 changes: 2 additions & 2 deletions MindboxSdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Pod::Spec.new do |s|

s.dependency "React-Core"

s.dependency "Mindbox", "2.14.4"
s.dependency "MindboxNotifications", "2.14.4"
s.dependency "Mindbox", "2.14.5"
s.dependency "MindboxNotifications", "2.14.5"
end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api 'cloud.mindbox:mobile-sdk:2.14.4'
api 'cloud.mindbox:mobile-sdk:2.14.5'
}
43 changes: 33 additions & 10 deletions android/src/main/java/com/mindboxsdk/MindboxSdkLifecycleListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ internal class MindboxSdkLifecycleListener private constructor(
application: Application,
onReady: (ReactContext) -> Unit
) {
val reactApplication = application.getReactApplication() ?: return
val reactInstanceManager = getReactInstanceManager()

val wrapperListener = object : ReactInstanceManager.ReactInstanceEventListener {
private val called = AtomicBoolean(false)
override fun onReactContextInitialized(context: ReactContext) {
if (called.compareAndSet(false, true)) {
Mindbox.writeLog("[RN] ReactContext initialized (listener)", Level.INFO)
onReady(context)
}
}
Expand All @@ -90,14 +90,19 @@ internal class MindboxSdkLifecycleListener private constructor(
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
if (!isMainActivity(activity)) return

getReactInstanceManager()?.currentReactContext?.let {
onReactContextAvailable(it, activity)
Mindbox.writeLog("[RN] ReactContext already available; skipping listener registration ", Level.INFO)
return
}
val hasConsumedReactContext = AtomicBoolean(false)

registerReactContextListener(application) { reactContext ->
onReactContextAvailable(reactContext, activity)
if (hasConsumedReactContext.compareAndSet(false, true)) {
onReactContextAvailable(reactContext, activity)
}
}

getReactContext()?.let {
if (hasConsumedReactContext.compareAndSet(false, true)) {
onReactContextAvailable(it, activity)
Mindbox.writeLog("[RN] ReactContext available (pre-existing)", Level.INFO)
}
}
}

Expand Down Expand Up @@ -129,9 +134,7 @@ internal class MindboxSdkLifecycleListener private constructor(
override fun onActivityDestroyed(activity: Activity) {
if (!isMainActivity(activity)) return
subscriber.onEvent(MindboxSdkLifecycleEvent.ActivityDestroyed(activity))
getReactInstanceManager()
?.currentReactContext
?.removeActivityEventListener(activityEventListener)
getReactContext()?.removeActivityEventListener(activityEventListener)
activityEventListener = null
}

Expand All @@ -153,6 +156,26 @@ internal class MindboxSdkLifecycleListener private constructor(

private fun Application.getReactApplication() = this as? ReactApplication

private fun getReactContext(): ReactContext? {
return getReactInstanceManagerContext() ?: getReactHostContext(application)
}

private fun getReactInstanceManagerContext(): ReactContext? {
return getReactInstanceManager()?.currentReactContext
}

private fun getReactHostContext(application: Application): ReactContext? =
runCatching {
// RN 0.78+ moves reactContext from reactNativeHost.reactInstanceManager to reactHost
val reactApplication = application as ReactApplication
val getHostMethod = reactApplication.javaClass.getMethod("getReactHost")
val reactHost = getHostMethod.invoke(reactApplication)
val getContextMethod = reactHost.javaClass.getMethod("getCurrentReactContext")
getContextMethod.invoke(reactHost) as? ReactContext
}.onFailure {
Mindbox.writeLog("[RN] ReactHost currentReactContext unavailable", Level.INFO)
}.getOrNull()

private fun addReactHostListener(
application: Application,
wrapperListener: ReactInstanceManager.ReactInstanceEventListener
Expand Down
10 changes: 10 additions & 0 deletions ios/MindboxJsDeliveryBridge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Foundation
import UserNotifications

@objc(MindboxJsDeliveryBridge)
public final class MindboxJsDeliveryBridge: NSObject {

@objc public static func emit(_ response: UNNotificationResponse) {
MindboxJsDelivery.emitEvent(response)
}
}
1 change: 0 additions & 1 deletion ios/MindboxSdk.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Mindbox
import MindboxLogger
import CoreFoundation

enum CustomError: Error {
case tokenAPNSisNull
Expand Down
4 changes: 4 additions & 0 deletions ios/MindboxSdk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
61249CFA2719673B00FC4033 /* MindboxJsDelivery.m in Sources */ = {isa = PBXBuildFile; fileRef = 61249CF92719673B00FC4033 /* MindboxJsDelivery.m */; };
D0F7B0012B1C4A1A00A1B2C3 /* MindboxJsDeliveryBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F7B0002B1C4A1A00A1B2C3 /* MindboxJsDeliveryBridge.swift */; };
F4FF95D7245B92E800C19C63 /* MindboxSdk.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FF95D6245B92E800C19C63 /* MindboxSdk.swift */; };
/* End PBXBuildFile section */

Expand All @@ -28,6 +29,7 @@
61249CF82719673B00FC4033 /* MindboxJsDelivery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MindboxJsDelivery.h; sourceTree = "<group>"; };
61249CF92719673B00FC4033 /* MindboxJsDelivery.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MindboxJsDelivery.m; sourceTree = "<group>"; };
B3E7B5891CC2AC0600A0062D /* MindboxSdk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MindboxSdk.m; sourceTree = "<group>"; };
D0F7B0002B1C4A1A00A1B2C3 /* MindboxJsDeliveryBridge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MindboxJsDeliveryBridge.swift; sourceTree = "<group>"; };
F4FF95D5245B92E700C19C63 /* MindboxSdk-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MindboxSdk-Bridging-Header.h"; sourceTree = "<group>"; };
F4FF95D6245B92E800C19C63 /* MindboxSdk.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MindboxSdk.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -56,6 +58,7 @@
children = (
61249CF82719673B00FC4033 /* MindboxJsDelivery.h */,
61249CF92719673B00FC4033 /* MindboxJsDelivery.m */,
D0F7B0002B1C4A1A00A1B2C3 /* MindboxJsDeliveryBridge.swift */,
F4FF95D6245B92E800C19C63 /* MindboxSdk.swift */,
B3E7B5891CC2AC0600A0062D /* MindboxSdk.m */,
F4FF95D5245B92E700C19C63 /* MindboxSdk-Bridging-Header.h */,
Expand Down Expand Up @@ -121,6 +124,7 @@
buildActionMask = 2147483647;
files = (
61249CFA2719673B00FC4033 /* MindboxJsDelivery.m in Sources */,
D0F7B0012B1C4A1A00A1B2C3 /* MindboxJsDeliveryBridge.swift in Sources */,
F4FF95D7245B92E800C19C63 /* MindboxSdk.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mindbox-sdk",
"version": "2.14.5",
"target-version": "2.14.5",
"target-version": "2.14.6",
"description": "SDK for integration React Native mobile apps with Mindbox",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
Loading