github bizz84/SwiftyStoreKit 0.8.0
Simplified error checking API

This release makes it easy to check if the user has canceled a purchase.

This is an API breaking change as the PurchaseError type has been removed in favour of SKError. Clients can now make purchases and check errors like this:

SwiftyStoreKit.purchaseProduct("com.musevisions.SwiftyStoreKit.Purchase1", atomically: true) { result in
    switch result {
    case .success(let product):
        print("Purchase Success: \(product.productId)")
    case .error(let error):
        switch error.code {
        case .unknown: print("Unknown error. Please contact support")
        case .clientInvalid: print("Not allowed to make the payment")
        case .paymentCancelled: break
        case .paymentInvalid: print("The purchase identifier was invalid")
        case .paymentNotAllowed: print("The device is not allowed to make the payment")
        case .storeProductNotAvailable: print("The product is not available in the current storefront")
        case .cloudServicePermissionDenied: print("Access to cloud service information is not allowed")
        case .cloudServiceNetworkConnectionFailed: print("Could not connect to the network")
        }
    }
}

This is in line with: https://developer.apple.com/reference/storekit/skerror.code

Related PR: https://github.com/bizz84/SwiftyStoreKit/pull/138

latest releases: 0.16.3, 0.16.2, 0.16.1...
4 years ago