launch static method

Future<LaunchCampaignResult> launch({
  1. String? label,
  2. String? url,
  3. dynamic onPaywallAction(
    1. NamiPaywallEvent?
    )?,
})

Launch a campaign to raise a paywall

Optionally you can provide,

  • A label to identify a campaign placement by label
  • A url to identify a deeplink campaign placement by url
  • A onPaywallAction callback to listen for the actions triggered on paywall

Implementation

static Future<LaunchCampaignResult> launch(
    {String? label,
    String? url,
    Function(NamiPaywallEvent?)? onPaywallAction}) async {
  // Listen for the paywall action event
  _paywallActionEvent.receiveBroadcastStream().listen((event) {
    if (event != null) {
      NamiPaywallEvent paywallEvent = _toNamiPaywallEvent(event);
      onPaywallAction!(paywallEvent);
    }
  });

  var variableMap = {"label": label, "url": url};

  final result = await channel.invokeMethod("launch", variableMap);
  var error = (result['error'] as String?)._toLaunchCampaignError();

  return LaunchCampaignResult(result['success'] ?? false, error);
}