setDelegate method

Future<void> setDelegate(
  1. SKPaymentQueueDelegateWrapper? delegate
)

Sets an implementation of the SKPaymentQueueDelegateWrapper.

The SKPaymentQueueDelegateWrapper can be used to inform iOS how to finish transactions when the storefront changes or if the price consent sheet should be displayed when the price of a subscription has changed. If no delegate is registered iOS will fallback to it's default configuration. See the documentation on StoreKite's -[SKPaymentQueue delegate:].

When set to null the payment queue delegate will be removed and the default behaviour will apply (see documentation).

Implementation

Future<void> setDelegate(SKPaymentQueueDelegateWrapper? delegate) async {
  if (delegate == null) {
    await _hostApi.removePaymentQueueDelegate();
    paymentQueueDelegateChannel.setMethodCallHandler(null);
  } else {
    await _hostApi.registerPaymentQueueDelegate();
    paymentQueueDelegateChannel
        .setMethodCallHandler(handlePaymentQueueDelegateCallbacks);
  }

  _paymentQueueDelegate = delegate;
}