startProductRequest method

Future<SkProductResponseWrapper> startProductRequest(
  1. List<String> productIdentifiers
)

Fetches product information for a list of given product identifiers.

The productIdentifiers should contain legitimate product identifiers that you declared for the products in the iTunes Connect. Invalid identifiers will be stored and returned in SkProductResponseWrapper.invalidProductIdentifiers. Duplicate values in productIdentifiers will be omitted. If productIdentifiers is null, an storekit_invalid_argument error will be returned. If productIdentifiers is empty, a SkProductResponseWrapper will still be returned with SkProductResponseWrapper.products being null.

SkProductResponseWrapper is returned if there is no error during the request. A PlatformException is thrown if the platform code making the request fails.

Implementation

Future<SkProductResponseWrapper> startProductRequest(
    List<String> productIdentifiers) async {
  final Map<String, dynamic>? productResponseMap =
      await channel.invokeMapMethod<String, dynamic>(
    '-[InAppPurchasePlugin startProductRequest:result:]',
    productIdentifiers,
  );
  if (productResponseMap == null) {
    throw PlatformException(
      code: 'storekit_no_response',
      message: 'StoreKit: Failed to get response from platform.',
    );
  }
  return SkProductResponseWrapper.fromJson(productResponseMap);
}