> For the complete documentation index, see [llms.txt](https://docs.namiml.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.namiml.com/sdk-reference/namicampaignmanager/launch.md).

# launch

#### Launch a campaign with the specified label

{% tabs %}
{% tab title="Swift" %}

```swift
NamiCampaignManager.launch(label: String)
```

{% endtab %}

{% tab title="Kotlin" %}

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

{% endtab %}

{% tab title="Flutter" %}

```dart
NamiCampaignManager.launch(label: "onboarding");
```

{% endtab %}

{% tab title="React Native" %}

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

{% endtab %}

{% tab title="Unity" %}

```cpp
NamiCampaignManager.Launch("onboarding");
```

{% endtab %}
{% endtabs %}

**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.

{% tabs %}
{% tab title="Swift" %}

```swift
NamiCampaignManager.launch(label: "a_label", launchHandler: { success, error in
   // callback with success (bool) or error (LaunchCampaignError)               
})
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
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}"
                )
            }
        }     
    }
}
```

{% endtab %}

{% tab title="Flutter" %}

```dart
// 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");
}
```

{% endtab %}

{% tab title="React Native" %}

```javascript
import {NamiCampaignManager, NamiCampaign} from 'react-native-nami-sdk';

NamiCampaignManager.launch(
  label,
  (successAction, error) => {
    console.log('successAction', successAction);
    console.log('error', error);
  });
```

{% endtab %}

{% tab title="Unity" %}

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

{% endtab %}
{% endtabs %}

#### 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.

{% tabs %}
{% tab title="Swift" %}

```swift
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")

    })
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
// 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}")
        }
    }
               
```

{% endtab %}

{% tab title="Flutter" %}

```dart
// 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);
```

{% endtab %}

{% tab title="React Native" %}

```javascript
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);
  },
);
```

{% endtab %}

{% tab title="Unity" %}

```cpp
// 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);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.namiml.com/sdk-reference/namicampaignmanager/launch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
