Launch a live campaign in your app and show the associated paywall

📘

If you are running older versions of the SDK, you will need to use the raisePaywall function. See the v1.0 docs.

NamiCampaignManager.launch()
NamiCampaignManager.launch(activity: Activity)
NamiCampaignManager.launch();

Launch a campaign with the specified label

NamiCampaignManager.launch(label: String)
NamiCampaignManager.launch(activity: Activity, label: String)

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}"
                )
            }
        }     
    }
}
NamiCampaignManager.launch();

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: { action, skuId -> () in

        switch action {
        case .close_paywall:
            print("paywall action - paywall closed")

        case .restore_purchases:
            print("paywall action - restore purchases tapped")

        case .sign_in:
            print("paywall action - sign in tapped")

        case .buy_sku:
            print("paywall action - buy sku tapped with sku: \(String(describing: skuId))")

        case .select_sku:
            print("paywall action - sku selected: \(String(describing: skuId))")

        case .purchase_selected_sku:
            print("paywall action - purchase flow started with selected sku: \(String(describing: skuId))")

        default:
            print("paywall action - unknown \(action.rawValue) skuId: \(skuId)")
        }
    })
NamiCampaignManager.launch(activity, label, paywallActionCallback = { action, skuId ->
    Log.d(LOG_TAG, "New Paywall Action $action with ${skuId.orEmpty()}")
}) { 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}")
        }
    }
}