initialize method

  1. @override
Future<String?> initialize({
  1. required String apiKey,
  2. HeliumCallbacks? callbacks,
  3. HeliumPurchaseDelegate? purchaseDelegate,
  4. Widget? fallbackPaywall,
  5. String? customAPIEndpoint,
  6. String? customUserId,
  7. Map<String, dynamic>? customUserTraits,
  8. String? revenueCatAppUserId,
  9. String? fallbackBundleAssetPath,
  10. HeliumPaywallLoadingConfig? paywallLoadingConfig,
})
override

Initialize helium sdk at the start up of flutter application. It will download custom paywall view

Implementation

@override
Future<String?> initialize({
  required String apiKey,
  HeliumCallbacks? callbacks,
  HeliumPurchaseDelegate? purchaseDelegate,
  Widget? fallbackPaywall,
  String? customAPIEndpoint,
  String? customUserId,
  Map<String, dynamic>? customUserTraits,
  String? revenueCatAppUserId,
  String? fallbackBundleAssetPath,
  HeliumPaywallLoadingConfig? paywallLoadingConfig,
}) async {
  _setMethodCallHandlers(callbacks, purchaseDelegate);
  _fallbackPaywallWidget = fallbackPaywall;

  if (_isInitialized) {
    return "[Helium] Already initialized!";
  }
  _isInitialized = true;

  final result = await methodChannel
      .invokeMethod<String?>(initializeMethodName, {
    'apiKey': apiKey,
    'customUserId': customUserId,
    'customAPIEndpoint': customAPIEndpoint,
    'customUserTraits': _convertBooleansToMarkers(customUserTraits),
    'revenueCatAppUserId': revenueCatAppUserId,
    'fallbackAssetPath': fallbackBundleAssetPath,
    'paywallLoadingConfig': _convertBooleansToMarkers(paywallLoadingConfig?.toMap()),
    'useDefaultDelegate': purchaseDelegate == null,
  });
  return result;
}