IOS-Inn_App_Purchase
绿色清真软件:以服务您为目标,开发未来 **仅支持非消耗产品**
- 订阅功能将未来支持!
- 库使用Sqlite处理您的产品,您不需要实现检查产品状态。
- 库在每次应用启动时检查您的产品状态。您可以看到。
请仔细阅读
- 在您的应用新鲜安装时,为了更好的用户体验,每个产品都返回为true(成功)。您的应用重新启动后,您将获得应用产品的实际状态。
RootViewController
创建一个产品唯一标识符的‘Set’字符串
- 示例
let listOfApplicationSKU : Set = ["sku.bor","sku.gas","sku.noads","sku.pro","sku.sun"]
在您的RootViewController中调用带枚举参数CallType.CheckProductStatus的ConnectToApple方法。此方法返回您的产品状态。
ConnectToApple.shared.billingSKUS(listApplicationSKU: listOfApplicationSKU)
.startToWork(type: ConnectToApple.CallType.CheckProductStatus).statusOfProducts(){ status in
for row in status{
if row.productIdentifier == "sku.bor" {
self.lblBorChecking.text = row.isPurchased.description
}else if row.productIdentifier == "sku.gas" {
self.lblGasChecking.text = row.isPurchased.description
}else if row.productIdentifier == "sku.noads" {
self.lblNoAdsChecking.text = row.isPurchased.description
}else if row.productIdentifier == "sku.pro" {
self.lblProChecking.text = row.isPurchased.description
}else if row.productIdentifier == "sku.sun" {
self.lblSunChecking.text = row.isPurchased.description
}
print("YHY : \(row.productIdentifier) : Status : \(BillingDB.shared.whatIsStatus(skuName: row.productIdentifier))")
}
}
注意:“ConnectToApple.CallType”函数有以下的枚举参数*
public enum CallType{
case GetPriceProducts
case CheckProductStatus
}
在RootVC中使用CheckProductStatus
在购买ViewController中使用GetPriceProducts
**您可以使用以下函数检查产品状态
BillingDB.shared.whatIsStatus(skuName: productIdentifier)
用于获取您的产品价格
ConnectToApple.shared.billingSKUS(listApplicationSKU: listOfApplicationSKU)
.startToWork(type: ConnectToApple.CallType.GetPriceProducts).pricesOfProducts(completionHandler: { success , products in
for p in products! {
if p.productIdentifier == "sku.bor" {
//self.product = p
self.btnBor.setTitle(self.setPriceText(product: p), for: .normal)
//self.setPriceOfLicense(price: p.price.floatValue)
}else if p.productIdentifier == "sku.gas" {
self.btnGas.setTitle(self.setPriceText(product: p), for: .normal)
}else if p.productIdentifier == "sku.noads" {
self.btnNoAds.setTitle(self.setPriceText(product: p), for: .normal)
}else if p.productIdentifier == "sku.pro" {
self.btnPro.setTitle(self.setPriceText(product: p), for: .normal)
}else if p.productIdentifier == "sku.sun" {
self.btnSun.setTitle(self.setPriceText(product: p), for: .normal)
}
self.isReady = true
self.buyProductDic[p.productIdentifier] = p
//YHYHud.shared.hideHud()
//print("Found product: \(p.productIdentifier) \(p.localizedTitle) \(p.price.floatValue)")
//print(2)
}
YHYHud.shared.hideHud()
}
).boughtProduct(){ productIdentifier, isBought in
if isBought{
self.showToastMsg(title : "Success",message: "License Loaded... Re-Open App")
ConnectToApple.shared.quitApp()
}else{
self.showToastMsg(title: "Fail..", message: "")
}
}