react-native-nami-sdk 3.3.3-5 → 3.3.3-6

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.
@@ -85,8 +85,8 @@ dependencies {
85
85
  implementation fileTree(dir: 'libs', include: ['*.jar'])
86
86
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
87
87
 
88
- playImplementation "com.namiml:sdk-android:3.3.3.4"
89
- amazonImplementation "com.namiml:sdk-amazon:3.3.3.4"
88
+ playImplementation "com.namiml:sdk-android:3.3.3.5"
89
+ amazonImplementation "com.namiml:sdk-amazon:3.3.3.5"
90
90
 
91
91
  implementation "com.facebook.react:react-native:+" // From node_modules
92
92
  coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4"
@@ -9,6 +9,7 @@ import com.facebook.react.module.annotations.ReactModule
9
9
  import com.facebook.react.modules.core.DeviceEventManagerModule
10
10
  import com.facebook.react.turbomodule.core.interfaces.TurboModule
11
11
  import com.namiml.billing.NamiPurchase
12
+ import com.namiml.campaign.LaunchCampaignError
12
13
  import com.namiml.campaign.LaunchCampaignResult
13
14
  import com.namiml.campaign.NamiCampaign
14
15
  import com.namiml.campaign.NamiCampaignManager
@@ -277,17 +278,46 @@ class NamiCampaignManagerBridgeModule internal constructor(
277
278
  }
278
279
  }
279
280
 
281
+ /**
282
+ * Maps Android LaunchCampaignError enum values to iOS-compatible error codes
283
+ * to ensure consistent error handling across platforms in React Native.
284
+ */
285
+ private fun mapErrorCodeToIOS(androidError: LaunchCampaignError): Int =
286
+ when (androidError) {
287
+ LaunchCampaignError.DEFAULT_CAMPAIGN_NOT_FOUND -> 0
288
+ LaunchCampaignError.LABELED_CAMPAIGN_NOT_FOUND -> 1
289
+ LaunchCampaignError.CAMPAIGN_DATA_NOT_FOUND -> 2
290
+ LaunchCampaignError.PAYWALL_ALREADY_DISPLAYED -> 3
291
+ LaunchCampaignError.SDK_NOT_INITIALIZED -> 4
292
+ LaunchCampaignError.URL_CAMPAIGN_NOT_FOUND -> 6
293
+ LaunchCampaignError.PRODUCT_GROUPS_NOT_FOUND -> 8
294
+ }
295
+
280
296
  private fun handleResult(
281
297
  result: LaunchCampaignResult,
282
298
  resultCallback: Callback,
283
299
  ) {
284
- val resultMap = Arguments.createMap()
285
300
  when (result) {
286
301
  is LaunchCampaignResult.Success -> {
287
302
  resultCallback.invoke(true)
288
303
  }
289
304
  is LaunchCampaignResult.Failure -> {
290
- resultCallback.invoke(false, "${result.error}")
305
+ val error = result.error
306
+ val errorInfo =
307
+ if (error is LaunchCampaignError) {
308
+ Arguments.createMap().apply {
309
+ putInt("code", mapErrorCodeToIOS(error))
310
+ putString("domain", "LaunchCampaignError")
311
+ putString("message", error.errorMessage.ifEmpty { error.toString() })
312
+ }
313
+ } else {
314
+ Arguments.createMap().apply {
315
+ putInt("code", -1)
316
+ putString("domain", "Unknown")
317
+ putString("message", error.toString())
318
+ }
319
+ }
320
+ resultCallback.invoke(false, errorInfo)
291
321
  }
292
322
  }
293
323
  }
@@ -2,4 +2,4 @@
2
2
  * Auto-generated file. Do not edit manually.
3
3
  * React Native Nami SDK version.
4
4
  */
5
- export declare const NAMI_REACT_NATIVE_VERSION = "3.3.3-5";
5
+ export declare const NAMI_REACT_NATIVE_VERSION = "3.3.3-6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nami-sdk",
3
- "version": "3.3.3-5",
3
+ "version": "3.3.3-6",
4
4
  "description": "React Native SDK for Nami - No-code paywall management with A/B testing.",
5
5
  "main": "index.ts",
6
6
  "types": "dist/index.d.ts",
package/src/version.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * Auto-generated file. Do not edit manually.
3
3
  * React Native Nami SDK version.
4
4
  */
5
- export const NAMI_REACT_NATIVE_VERSION = '3.3.3-5';
5
+ export const NAMI_REACT_NATIVE_VERSION = '3.3.3-6';