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 SKProductsResponseMessage productResponsePigeon =
      await _hostApi.startProductRequest(productIdentifiers);

  // should products be null or <String>[] ?
  if (productResponsePigeon.products == null) {
    throw PlatformException(
      code: 'storekit_no_response',
      message: 'StoreKit: Failed to get response from platform.',
    );
  }

  return SkProductResponseWrapper.convertFromPigeon(productResponsePigeon);
}