ios - InAppPurchase doesnt work -
im making game , got problem: every time i'm making purchase in it, returns me failed transaction. call function start transaction:
func buyproduct() { let payment:skpayment = skpayment(product: product) skpaymentqueue.defaultqueue().addpayment(payment) }
i got several users in sandbox-testers , set price in-app-purchase free. what's problem?
var product: skproduct! //used in viewdidload skpaymentqueue.defaultqueue().addtransactionobserver(self) self.getproductinfo() func productsrequest(request: skproductsrequest!, didreceiveresponse response: skproductsresponse!) { let products = response.products if (products.count != 0){ product = products[0] as! skproduct } } func getproductinfo() { if (skpaymentqueue.canmakepayments()){ let productid:nsset = nsset(object: "id.unique") let request:skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>) request.delegate = self request.start() } } func paymentqueue(queue: skpaymentqueue!, updatedtransactions transactions: [anyobject]!) { transaction:anyobject in transactions { if let trans:skpaymenttransaction = transaction as? skpaymenttransaction{ switch trans.transactionstate{ case .purchased: self.removeads() println("success") skpaymentqueue.defaultqueue().finishtransaction(transaction as! skpaymenttransaction) break case .failed: println("failed") showalert("error", message: "ooops, there transaction problem") skpaymentqueue.defaultqueue().finishtransaction(transaction as! skpaymenttransaction) break case .restored: println("restored") skpaymentqueue.defaultqueue().restorecompletedtransactions() break default: break } } } }
did test on real device?
in app purchase not work on simulator, failed error this.
error domain=skerrordomain code=0 "cannot connect itunes store" userinfo=0x7f98b8fda180 {nslocalizeddescription=cannot connect itunes store}
Comments
Post a Comment