Дім*_*мар 17 in-app-purchase ios swift
我已经为我的项目配置了IAP,它似乎工作,所以我的应用程序在应用程序商店上运行,但我发现大约30%的请求iTunes由于某种原因返回invalidProductIdentifier,下面是完整的代码:
class IAP: NSObject, SKProductsRequestDelegate {
static let sharedInstance = IAP()
func productsRequest(request: SKProductsRequest, didReceiveResponse response: SKProductsResponse) {
response.invalidProductIdentifiers.forEach() { id in
//here is the part that could fail sometimes
print(id)
}
}
//here how I setup IAP
func canMakePayments() {
if(SKPaymentQueue.canMakePayments()) {
var productID = NSSet()
productID = NSSet(object: "unlock")
let request: SKProductsRequest = SKProductsRequest(productIdentifiers: productID as! Set<String>)
request.delegate = self
request.start()
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这里我如何使用它AppDelegate:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
IAP.sharedInstance.canMakePayments()
return true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
441 次 |
| 最近记录: |