swift - In app purchase in SKScene not working? -


i'm creating spritekit game in swift , i'm trying implement in app purchases.

i followed question here: in app purchase in skscene

and here code:

in didmovetoview:

 // set iaps         if(skpaymentqueue.canmakepayments()) {             println("iap enabled, loading")             var productid:nsset = nsset(objects: "gameoversavesavior")             var request: skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>)             request.delegate = self             request.start()         } else {             println("please enable iaps")         } 

outside of didmovetoview in gamescene:

 //in app purchase ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++      var productlist = [skproduct]()     var p = skproduct()      func purchasemade() {         println("they bought it!")     }      func buyproduct() {         println("buy" + p.productidentifier)          var pay = skpayment(product: p)         skpaymentqueue.defaultqueue().addtransactionobserver(self)         skpaymentqueue.defaultqueue().addpayment(pay skpayment)     }     func productsrequest(request: skproductsrequest!, didreceiveresponse response: skproductsresponse!) {         println("product request")         var myproduct = response.products          product in myproduct {             println("product added")             println(product.productidentifier)             println(product.localizedtitle)             println(product.localizeddescription)             println(product.price)              productlist.append(product as! skproduct)         }     }      func paymentqueuerestorecompletedtransactionsfinished(queue: skpaymentqueue!) {         println("transactions restored")          var purchaseditemids = []         transaction in queue.transactions {             var t: skpaymenttransaction = transaction as! skpaymenttransaction              let prodid = t.payment.productidentifier string              switch prodid {             case "gameoversavesavior":                  purchasemade()                  //right here should put function want execute when in app purchase complete             default:                 println("iap not setup")             }          }          var alert = uialertview(title: "thank you", message: "your purchase(s) restored. may have restart app before banner ads removed.", delegate: nil, cancelbuttontitle: "ok")         alert.show()     }       func paymentqueue(queue: skpaymentqueue!, updatedtransactions transactions: [anyobject]!) {         println("add paymnet")          transaction:anyobject in transactions {             var trans = transaction as! skpaymenttransaction             println(trans.error)              switch trans.transactionstate {              case .purchased, .restored:                 println("buy, ok unlock iap here")                 println(p.productidentifier)                  let prodid = p.productidentifier string                 switch prodid {                 case "gameoversavesavior":                      //here should put function want execute when purchase complete                     var alert = uialertview(title: "thank you", message: "you may have restart app before banner ads removed.", delegate: nil, cancelbuttontitle: "ok")                     alert.show()                 default:                     println("iap not setup")                 }                  queue.finishtransaction(trans)                 break;             case .failed:                 println("buy error")                 queue.finishtransaction(trans)                 break;             default:                 println("default")                 break;              }         }     }      func finishtransaction(trans:skpaymenttransaction)     {         println("finish trans")     }     func paymentqueue(queue: skpaymentqueue!, removedtransactions transactions: [anyobject]!)     {         println("remove trans");     }   //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 

in touchesbegan when in app purchase node touched:

//in app purchase             if touchednode == savemebtn {                  println("button touched!")                 product in productlist {                     var prodid = product.productidentifier                     if(prodid == "gameoversavesavior") {                         p = product                         buyproduct()  //this 1 of functions added earlier                         break;                     }                 } 

all of code straight question above, , code compiles without errors ,

iap enabled, loading

and

product request

is printed console @ start of game.

when in app purchase button touched,

button touched!

is printed console nothing else happens. doesn't ask user purchase anything.

i made sure bundle id in xcode same in itunes connect , in app purchase id same. doing wrong here?

after few weeks of work, found out must have paid applications agreement filled out , accepted in order code , products work. approval can take few days, you're in clear.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -