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

NamiCampaignManager.launch()
NamiCampaignManager.launch(activity: Activity)
NamiCampaignManager.launch();
import {NamiCampaignManager, NamiCampaign} from 'react-native-nami-sdk';

NamiCampaignManager.launch('', (success, error) => {
  console.log('success', success);
  console.log('error', error);
});
NamiCampaignManager.Launch();

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 the campaign, with a label, and use of an error handler
LaunchCampaignResult result;
result = await NamiCampaignManager.launch(label: "onboarding");
if (result.success) {
  print("Launch campaign - success");
} else {
  print("Launch campaign - error");
}
import {NamiCampaignManager, NamiCampaign} from 'react-native-nami-sdk';

NamiCampaignManager.launch(
  label,
  (successAction, error) => {
    console.log('successAction', successAction);
    console.log('error', error);
  });
// Launch a campaign with an error handler
var launchHandler = new LaunchHandler((isSuccess, errorMsg) =>
{
    // on launch
});
NamiCampaignManager.Launch("onboarding", launchHandler);

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}")
        }
    }
               
// Launch the campaign, with a label, and use of an error handler
LaunchCampaignResult result;
result = await NamiCampaignManager.launch(
  label: "onboarding",
  onPaywallAction: (action, sku) {
      print("Paywall action $action");
});
if (result.success) {
  print("Launch campaign - success");
} else {
  print("Launch campaign - error");
}// Launch the campaign with paywall interaction callbacks
// - Android paywallActionHandler
var paywallActionHandler = new PaywallActionHandler((namiPaywallAction, sku) =>
{
    // on paywall action
});
// - iOS paywallActionHandler
var paywallActionHandler = new PaywallActionHandler((namiPaywallAction, sku, errorMsg, purchases) =>
{
    // on paywall action
});
NamiCampaignManager.Launch("onboarding", launchHandler, paywallActionHandler);
import {NamiCampaignManager, NamiCampaign} from 'react-native-nami-sdk';

NamiCampaignManager.launch(
  label,
  (successAction, error) => {
    console.log('successAction', successAction);
    console.log('error', error);
  },
  (
    action,
    skuId,
    purchaseError,
    purchases,
    campaignId,
    campaignLabel,
    paywallId,
  ) => {
    console.log('action', action);
    console.log('skuId', skuId);
    console.log('purchaseError', purchaseError);
    console.log('purchases', purchases);
    console.log('campaignId', campaignId);
    console.log('campaignLabel', campaignLabel);
    console.log('paywallId', paywallId);
  },
);
// Launch the campaign with paywall interaction callbacks
// - Android paywallActionHandler
var paywallActionHandler = new PaywallActionHandler((namiPaywallAction, sku) =>
{
    // on paywall action
});
// - iOS paywallActionHandler
var paywallActionHandler = new PaywallActionHandler((namiPaywallAction, sku, errorMsg, purchases) =>
{
    // on paywall action
});
NamiCampaignManager.Launch("onboarding", launchHandler, paywallActionHandler);