HPStore 1.2.1

HPStore 1.2.1

Henrik Panhans 维护。



HPStore 1.2.1

SimpleStore

SimpleStore 是一个基于 Apple 的 StoreKit 的轻量级框架,用于执行应用内购买。它几乎为您完成所有工作,让您可以专注于您自己的代码。

要安装,只需将 pod 'SimpleStore' 添加到您的 Podfile 或将 github "SwiftyJSON/SwiftyJSON" 添加到您的 Cartfile 中。

使用方法:只需用一个产品 ID 的数组初始化一个新的 SimpleStore 对象,指定代理,您就设置好了。它会自动为您请求产品信息。

import SimpleStore

var store = SimpleStore(with: [String])

store.delegate = self //see delegate methods below

以下功能可用:

store.checkIfPaymentPossible() // refreshes the canMakePayments Boolean

store.requestProductInfo(withIDs: [String]) // this will reload all products with the supplied identifiers

store.buyProduct(withID: String) // I recommend using an enum for this

属性

var productIDs = [String]()
var products = [String : SKProduct]()
var canMakePayments = true
var delegate: SimpleStoreDelegate?

代理方法

func purchaseDidSucceed(with id: String, transaction: SKPaymentTransaction) {}
    
func purchaseDidFail(with id: String, transaction: SKPaymentTransaction) {}

func purchaseDidRestore(with id: String, transaction: SKPaymentTransaction) {}

func restoreDidFail(with error: Error) {}

如果您有任何建议或改进,请随时贡献 :)