From bd16594fdcfa6471ca7f05bb06ee9f375f548264 Mon Sep 17 00:00:00 2001 From: dannami Date: Thu, 27 Jul 2023 07:48:19 -0600 Subject: [PATCH] update android bridge for 3.1.x --- .../com/nami/reactlibrary/NamiBridgeModule.kt | 2 +- .../reactlibrary/NamiCampaignManagerBridge.kt | 88 +++++-------------- .../NamiPaywallManagerBridgeModule.kt | 2 +- .../java/com/nami/reactlibrary/NamiUtil.kt | 3 +- ios/Nami.m | 2 +- package.json | 2 +- react-native-nami-sdk.podspec | 2 +- 7 files changed, 29 insertions(+), 72 deletions(-) diff --git a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt index c02215a7..24d3b116 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt @@ -115,7 +115,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } else { Arguments.createArray() } - val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.24") + val settingsList = mutableListOf("extendedClientInfo:react-native:3.0.25") namiCommandsReact?.toArrayList()?.filterIsInstance()?.let { commandsFromReact -> settingsList.addAll(commandsFromReact) } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt index 3be0257e..fc1b7543 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiCampaignManagerBridge.kt @@ -10,8 +10,6 @@ import com.namiml.billing.NamiPurchase import com.namiml.campaign.LaunchCampaignResult import com.namiml.campaign.NamiCampaign import com.namiml.campaign.NamiCampaignManager -import com.namiml.paywall.NamiSKU -import com.namiml.paywall.model.NamiPaywallAction import com.namiml.paywall.model.PaywallLaunchContext class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : @@ -92,42 +90,16 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : } else { paywallLaunchContext = PaywallLaunchContext(null, customAttributes) } - } if (theActivity != null) { reactApplicationContext.runOnUiQueueThread { val paywallActionCallback = { - campaignId: String, - campaignName: String?, - campaignType: String?, - campaignLabel: String?, - campaignUrl: String?, - paywallId: String, - paywallName: String?, - segmentId: String?, - externalSegmentId: String?, - action: NamiPaywallAction, - sku: NamiSKU?, - purchaseError: String?, - purchases: List?, - deeplinkUrl: String? -> + paywallEvent: NamiPaywallEvent -> handlePaywallCallback( - campaignId, - campaignName, - campaignType, - campaignLabel, - campaignUrl, - paywallId, - paywallName, - segmentId, - externalSegmentId, - action, - sku, - purchaseError, - purchases, - deeplinkUrl, - actionCallback) + paywallEvent, + actionCallback, + ) } val uriObject: Uri? = if (withUrl != null) Uri.parse(withUrl) else null @@ -154,48 +126,34 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) : } } } - } private fun handlePaywallCallback( - campaignId: String, - campaignName: String?, - campaignType: String?, - campaignLabel: String?, - campaignUrl: String?, - paywallId: String, - paywallName: String?, - segmentId: String?, - externalSegmentId: String?, - action: NamiPaywallAction, - sku: NamiSKU?, - purchaseError: String?, - purchases: List?, - deeplinkUrl: String?, - actionCallback: Callback + paywallEvent: NamiPaywallEvent, + actionCallback: Callback, ) { - val actionString = action.toString() - val skuString = sku?.skuId ?: "" + val actionString = paywallEvent.action.toString() + val skuString = paywallEvent.sku?.skuId ?: "" val purchasesArray = createPurchaseArray(purchases) val resultMap = Arguments.createMap().apply { - putString(CAMPAIGN_ID, campaignId) - putString(CAMPAIGN_LABEL, campaignLabel ?: "") - putString(PAYWALL_ID, paywallId) - putString(ACTION, actionString) + putString(CAMPAIGN_ID, paywallEvent.campaignId) + putString(CAMPAIGN_LABEL, paywallEvent.campaignLabel ?: "") + putString(PAYWALL_ID, paywallEvent.paywallId) + putString(ACTION, paywallEvent.actionString) putString(SKU_ID, skuString) - putString(PURCHASE_ERROR, purchaseError ?: "") - putArray(PURCHASES, purchasesArray) - putString(CAMPAIGN_NAME, campaignName ?: "") - putString(CAMPAIGN_TYPE, campaignType ?: "") - putString(CAMPAIGN_URL, campaignUrl ?: "") - putString(PAYWALL_NAME, paywallName ?: "") - putString(COMPONENT_CHANGE_ID, "") - putString(COMPONENT_CHANGE_NAME, "") - putString(SEGMENT_ID, segmentId ?: "") - putString(EXTERNAL_SEGMENT_ID, externalSegmentId ?: "") - putString(DEEP_LINK_URL, deeplinkUrl ?: "") + putString(PURCHASE_ERROR, paywallEvent.purchaseError ?: "") + putArray(PURCHASES, paywallEvent.purchasesArray) + putString(CAMPAIGN_NAME, paywallEvent.campaignName ?: "") + putString(CAMPAIGN_TYPE, paywallEvent.campaignType ?: "") + putString(CAMPAIGN_URL, paywallEvent.campaignUrl ?: "") + putString(PAYWALL_NAME, paywallEvent.paywallName ?: "") + putString(COMPONENT_CHANGE_ID, paywallEvent?.componentChange?.id ?: "") + putString(COMPONENT_CHANGE_NAME, paywallEvent?.componentChange?.name ?: "") + putString(SEGMENT_ID, paywallEvent.segmentId ?: "") + putString(EXTERNAL_SEGMENT_ID, paywallEvent.externalSegmentId ?: "") + putString(DEEP_LINK_URL, paywallEvent.deeplinkUrl ?: "") } emitEvent(_RESULT_CAMPAIGN, resultMap) diff --git a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt index 55c5448e..cff2af45 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt @@ -108,7 +108,7 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) : if (productId != null && skuId != null && skuType != null) { val namiSku = NamiSKU( skuId = skuId, - skuDetails = null, + productDetails = null, amazonProduct = null, id = productId, type = skuType, diff --git a/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt b/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt index 7a67720d..cbe2ec31 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiUtil.kt @@ -79,8 +79,7 @@ fun NamiSKU.toSkuDict(): WritableMap { productDict.putString("skuId", this.skuId) productDict.putString("id", this.id) productDict.putString("type", this.type.toString()) - productDict.putString("promoId","") - productDict.putString("promoToken","") + productDict.putString("promoId", "") return productDict } diff --git a/ios/Nami.m b/ios/Nami.m index 81a88cdc..31addc3b 100644 --- a/ios/Nami.m +++ b/ios/Nami.m @@ -52,7 +52,7 @@ @implementation NamiBridge (RCTExternModule) } // Start commands with header iformation for Nami to let them know this is a React client. - NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.24"]]; + NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.0.25"]]; // Add additional namiCommands app may have sent in. NSObject *appCommandStrings = configDict[@"namiCommands"]; diff --git a/package.json b/package.json index 2376677d..7c37811a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nami-sdk", - "version": "3.0.24", + "version": "3.0.25", "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.", "main": "index.js", "scripts": { diff --git a/react-native-nami-sdk.podspec b/react-native-nami-sdk.podspec index e4c44c9f..94f8d0b6 100644 --- a/react-native-nami-sdk.podspec +++ b/react-native-nami-sdk.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.requires_arc = true - s.dependency 'Nami', '3.1.1' + s.dependency 'Nami', '3.1.2' s.dependency 'React' end