StoreKitClient 0.7.0

StoreKitClient 0.7.0

测试已测试
Lang语言 SwiftSwift
许可 MIT
Released最后发布2019年10月
SPM支持SPM

Maintained by Daniel Clelland.



  • Daniel Clelland

StoreKitClient

Apple StoreKit IAP API的简单PromiseKit客户端。

主要基于现有的PromiseKit/StoreKit包装器.

依赖

示例

获取产品

let productIdentifiers: Set<String> = /* ... get product identifers */
StoreKitClient.getProducts(productIdentifiers: productIdentifiers).then { productsResponse in
    // Handle products...
}.catch { error in
    // Handle exception...
}

进行支付

let product: SKProduct = /* ... get product from `StoreKitClient.getProducts` */
let payment: SKPayment = SKPayment(product: product)
StoreKitClient.getTransaction(payment: payment).then { transaction in
    // Check `transaction.transactionState`...
}.catch { error in
    switch ((error as NSError).domain, (error as NSError).code) {
    case (SKErrorDomain, SKError.paymentCancelled.rawValue):
        // User cancelled, don't show an error...
    default:
        // Handle exception...
    }
}

获取完成的交易

StoreKitClient.getTransactions().then { transactions in
    // Handle completed transactions...
}.catch { error in
    // Handle exception...
}

刷新收据

StoreKitClient.getReceipt().then { receipt in
    // Check `Bundle.main.appStoreReceiptURL`...
}.catch { error in
    // Handle exception...
}