start static method

Future<void> start({
  1. String appId = "",
  2. String apiKey = "",
  3. String? userId,
  4. bool allowAnonymousPurchase = false,
  5. bool enableStorekitV2 = false,
  6. String lang = '',
  7. String environment = 'production',
})

Start Iaphub

Implementation

static Future<void> start(
    {String appId = "",
    String apiKey = "",
    String? userId,
    bool allowAnonymousPurchase = false,
    bool enableStorekitV2 = false,
    String lang = '',
    String environment = 'production'}) async {
  // Clear listeners
  removeAllListeners();
  // Add channel call handler
  _channel.setMethodCallHandler(_invokeListener);
  // Invoke start
  const sdkVersion = IaphubConfig.version;
  await _invokeMethod('start', {
    "appId": appId,
    "apiKey": apiKey,
    "userId": userId,
    "allowAnonymousPurchase": allowAnonymousPurchase,
    "enableStorekitV2": enableStorekitV2,
    "lang": lang,
    "environment": environment,
    "sdkVersion": sdkVersion
  });
  // Display product missing error
  addEventListener("onError", (err) {
    if (err.code == "unexpected" &&
        err.subcode == "product_missing_from_store") {
      debugPrint(err.message);
    }
  });
}