launch
Show a paywall or flow
Launch a campaign with the specified label
NamiCampaignManager.launch(label: String)NamiCampaignManager.launch(activity: Activity, label: String)NamiCampaignManager.launch(label: "onboarding");NamiCampaignManager.launch('onboarding', (success, error) => {
console.log('success', success);
console.log('error', error);
});NamiCampaignManager.Launch("onboarding");Parameters
label- a string matching the label set in the Control Center
Launch a campaign with a result callback
This can be used to know if the launch succeeded or failed to raise a paywall. Additionally, you can use this to monitor for purchase change events to observe what the outcomes of any system purchase flows initiated from the campaign launch.
NamiCampaignManager.launch(label: "a_label", launchHandler: { success, error in
// callback with success (bool) or error (LaunchCampaignError)
})NamiCampaignManager.launch(activity, "a_label") { result ->
when (result) {
is LaunchCampaignResult.Success -> {
// success
}
is LaunchCampaignResult.Failure -> {
// fail
Log.d(LOG_TAG, "Launch Campaign Error -> ${result.error}")
}
is LaunchCampaignResult.PurchaseChanged -> {
Log.d(
LOG_TAG,
"Launch Campaign Result - Purchase changed -> ${result.purchaseState}"
)
if (result.purchaseState == NamiPurchaseState.PURCHASED) {
Log.d(
LOG_TAG,
"NamiPurchaseState - Purchased -> ${result.activePurchases}"
)
}
}
}
}Launch a campaign with paywall interaction callback
Use this to monitor user interactions with the paywall raised by this campaign launch. Returns NamiPaywallAction events and an optional skuId if relevant to the action.
NamiCampaignManager.launch(label: label, launchHandler: { success, error in
print("campaign launch - success \(success) or error \(error)")
},
paywallActionHandler: { paywallEvent in
print("Campaign paywallActionHandler metadata: \n" +
"campaignId: \(String(describing: paywallEvent.campaignId))\n" +
"campaignName: \(String(describing: paywallEvent.campaignName))\n" +
"campaignType: \(String(describing: paywallEvent.campaignType))\n" +
"campaignLabel: \(String(describing: paywallEvent.campaignLabel))\n" +
"campaignUrl: \(String(describing: paywallEvent.campaignUrl))\n" +
"paywallId: \(String(describing: paywallEvent.paywallId))\n" +
"paywallName: \(String(describing: paywallEvent.paywallName))\n" +
"segmentId: \(String(describing: paywallEvent.segmentId))\n" +
"externalSegmentId: \(String(describing: paywallEvent.externalSegmentId))\n" +
"paywallLaunchContext: \(String(describing: paywallEvent.paywallLaunchContext))\n" +
"deeplinkUrl: \(String(describing: paywallEvent.deeplinkUrl))\n")
})// Launch the campaign with paywall interaction feedback handler
NamiCampaignManager.launch(activity, label, paywallActionCallback = { paywallEvent ->
Log.d(
LOG_TAG,
"${paywallEvent.action}",
)
Log.d(
LOG_TAG,
"\tcampaignId ${paywallEvent.campaignId}\n" +
"\tcampaignName ${paywallEvent.campaignName}\n" +
"\tcampaignType ${paywallEvent.campaignType}\n" +
"\tcampaignLabel ${paywallEvent.campaignLabel}\n" +
"\tcampaignUrl ${paywallEvent.campaignUrl}\n" +
"\tpaywallId ${paywallEvent.paywallId}\n" +
"\tpaywallName ${paywallEvent.paywallName}\n" +
"\tsegmentId ${paywallEvent.segmentId}\n" +
"\texternalSegmentId ${paywallEvent.externalSegmentId}\n" +
"\tdeepLinkUrl ${paywallEvent.deeplinkUrl}\n" +
"\tselectedItemId ${paywallEvent.componentChange?.id}\n" +
"\tselectedItemName ${paywallEvent.componentChange?.name}\n" +
"\tsku ${paywallEvent.sku?.skuId}\n" +
"\tpurchaseError ${paywallEvent.purchaseError}\n" +
"\tpurchaseError ${paywallEvent.purchases}\n",
)
}) { result ->
when (result) {
is LaunchCampaignResult.Success -> {
Log.d(LOG_TAG, "Launch Campaign Success")
}
is LaunchCampaignResult.Failure -> {
Log.d(LOG_TAG, "Launch Campaign Error -> ${result.error}")
}
}
Last updated