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
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ dependencies {
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.movableink.sdk:inked:2.1.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"

}

if (isNewArchitectureEnabled()) {
Expand Down
40 changes: 27 additions & 13 deletions android/src/main/java/com/rnmovableink/RNMovableInkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import com.facebook.react.bridge.Callback
import com.movableink.inked.MIClient
import com.movableink.inked.MIClient.setMIU
import com.movableink.inked.inAppMessage.MovableInAppClient
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch

class RNMovableInkModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
Expand All @@ -30,7 +33,7 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :

@ReactMethod
fun identifyUser() {

}

@ReactMethod
Expand Down Expand Up @@ -82,20 +85,31 @@ class RNMovableInkModule(reactContext: ReactApplicationContext) :
}
}

@ReactMethod
fun showInAppMessage(url: String, callback: Callback) {
currentActivity?.runOnUiThread {
MIClient.showInAppBrowser(
currentActivity!!,
url,
listener = object : MovableInAppClient.OnUrlLoadingListener {
override fun onButtonClicked(value: String) {
callback.invoke(value)
@ReactMethod
fun showInAppMessage(url: String, callback: Callback) {
val activity = currentActivity
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing null check for currentActivity. If currentActivity is null, the callback should be invoked with an error message to handle this edge case properly.

Suggested change
val activity = currentActivity
val activity = currentActivity
if (activity == null) {
callback.invoke("Error: currentActivity is null")
return
}

Copilot uses AI. Check for mistakes.
if (activity is androidx.lifecycle.LifecycleOwner) {
Comment on lines +90 to +91
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing else branch to handle the case when activity is not a LifecycleOwner. The callback should be invoked with an error message to prevent the caller from waiting indefinitely.

Copilot uses AI. Check for mistakes.
activity.lifecycleScope.launch {
try {
MIClient.showInAppBrowser(
activity,
url,
listener = object : MovableInAppClient.OnUrlLoadingListener {
override fun onButtonClicked(value: String) {
activity.runOnUiThread {
callback.invoke(value)
}
}
}
)
} catch (e: Exception) {
activity.runOnUiThread {
callback.invoke("Error: ${e.message}")
}
}
},
)
}
}
}
}

@ReactMethod
fun setValidPasteboardValues(values: ReadableArray) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@movable/react-native-sdk",
"version": "2.1.0",
"version": "2.1.1",
"description": "MovableInk React Native SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down