initialize method

Future<String?> initialize()

Initializes iap features for both Android and iOS.

This must be called on Android and iOS before purchasing. On iOS, it also checks if the client can make payments.

Implementation

Future<String?> initialize() async {
  if (_platform.isAndroid) {
    await _setPurchaseListener();
    return await _channel.invokeMethod('initConnection');
  } else if (_platform.isIOS) {
    await _setPurchaseListener();
    return await _channel.invokeMethod('canMakePayments');
  }
  throw PlatformException(
      code: _platform.operatingSystem, message: "platform not supported");
}