start static method
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);
}
});
// Check SDK version
final nativeSDKVersion = await _invokeMethodAndParseString('getSDKVersion', {});
if (Platform.isIOS && nativeSDKVersion != IaphubConfig.iosSDKVersion) {
debugPrint("The \"react-native-iaphub\" plugin requires the native IAPHUB iOS SDK version ${IaphubConfig.iosSDKVersion}.\n\nTo fix this issue:\nRun `pod update Iaphub` in the ios folder of your project to update the IAPHUB iOS SDK to the required version.");
}
else if (Platform.isAndroid && nativeSDKVersion != IaphubConfig.androidSDKVersion) {
debugPrint("The \"react-native-iaphub\" plugin requires the native IAPHUB Android SDK version ${IaphubConfig.androidSDKVersion}.\n\nTo fix this issue:\nRebuild your Android project to update the dependencies with the correct SDK version.");
}
}