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. HeliumEnvironment? environment,
  11. HeliumPaywallLoadingConfig? paywallLoadingConfig,
  12. Set<String>? androidConsumableProductIds,
})
override

Initialize helium sdk at the start-up of your flutter application.

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,
  HeliumEnvironment? environment,
  HeliumPaywallLoadingConfig? paywallLoadingConfig,
  Set<String>? androidConsumableProductIds,
}) async {
  _setMethodCallHandlers(callbacks, purchaseDelegate);
  _fallbackPaywallWidget = fallbackPaywall;

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

  try {
    final result =
        await methodChannel.invokeMethod<String?>(initializeMethodName,
            _buildNativeArgs(
              apiKey: apiKey,
              purchaseDelegate: purchaseDelegate,
              customAPIEndpoint: customAPIEndpoint,
              customUserId: customUserId,
              customUserTraits: customUserTraits,
              revenueCatAppUserId: revenueCatAppUserId,
              fallbackBundleAssetPath: fallbackBundleAssetPath,
              environment: environment,
              paywallLoadingConfig: paywallLoadingConfig,
              androidConsumableProductIds: androidConsumableProductIds,
            ));
    return result;
  } catch (e) {
    _isInitialized = false;
    rethrow;
  }
}