unsubscribe static method

Future<BaseResponse> unsubscribe(
  1. String purchaseToken
)

For iOS platform:

Navigates to Subscriptions page of the device. Apple does not allow developer to end subscriptions directly; instead, directs to the Subscriptions page of the device.

For Android platform:

Ends an ongoing subscription.

purchaseToken Token created after a purchase. It can be found inside PurchaseInfo object.

Callbacks boolean and GenericError in case of failure.

Implementation

/// #### For Android platform:
/// Ends an ongoing subscription.
///
/// [purchaseToken] Token created after a purchase. It can be found inside PurchaseInfo object.
///
/// Callbacks [boolean] and [GenericError] in case of failure.
static Future<BaseResponse> unsubscribe(String purchaseToken) async {
  List<Object?>? response = await _channel
      .invokeMethod('unsubscribe', {"purchaseToken": purchaseToken});
  BaseResponse result = new BaseResponse(false, null);
  if (response != null) {
    if (response[0] != null) {
      result = new BaseResponse(response[0].toString() == "true", null);
    }
    if (response[1] != null) {
      GenericError error =
          GenericError.fromJson(json.decode(response[1]!.toString()));
      result = new BaseResponse(false, error);
    }
    return result;
  }
  return result;
}