Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update native dependencies #225

Merged
merged 2 commits into from
Jul 27, 2023
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: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

implementation 'com.github.jeziellago:compose-markdown:0.3.0'
implementation "com.namiml:sdk-android:3.0.24"
implementation "com.namiml:sdk-android:3.1.0"

implementation 'com.facebook.react:react-native:+' // From node_modules
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>()?.let { commandsFromReact ->
settingsList.addAll(commandsFromReact)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ 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
import com.namiml.paywall.model.NamiPaywallEvent

class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
Expand Down Expand Up @@ -92,42 +91,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<NamiPurchase>?,
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
Expand All @@ -154,48 +127,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<NamiPurchase>?,
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 purchasesArray = createPurchaseArray(paywallEvent.purchases)

val resultMap = Arguments.createMap().apply {
putString(CAMPAIGN_ID, campaignId)
putString(CAMPAIGN_LABEL, campaignLabel ?: "")
putString(PAYWALL_ID, paywallId)
putString(CAMPAIGN_ID, paywallEvent.campaignId)
putString(CAMPAIGN_LABEL, paywallEvent.campaignLabel ?: "")
putString(PAYWALL_ID, paywallEvent.paywallId)
putString(ACTION, actionString)
putString(SKU_ID, skuString)
putString(PURCHASE_ERROR, purchaseError ?: "")
putString(PURCHASE_ERROR, paywallEvent.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(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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions android/src/main/java/com/nami/reactlibrary/NamiUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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", this.promoId)

return productDict
}
Expand Down
2 changes: 1 addition & 1 deletion ios/Nami.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
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": "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": {
Expand Down
2 changes: 1 addition & 1 deletion react-native-nami-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading