swift - Why doesn't my In App Purchase purchase the product? -


i'm calling function when press button unlock level nothing happens when this. runs function doesn't ask password or else. doing wrong?

func callthis() {      if(skpaymentqueue.canmakepayments()) {         println("iap enabled, loading")         var productid:nsset = nsset(object: "unlockleveltwoplease")         var request: skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>)         request.delegate = self         request.start()     } else {         println("please enable iaps")      } }    func callthis2() {      if(skpaymentqueue.canmakepayments()) {         println("iap enabled, loading")         var productid:nsset = nsset(object:  "unlocklevelthreeplease")         var request: skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>)         request.delegate = self         request.start()     } else {         println("please enable iaps")      } }    func callthis3() {      if(skpaymentqueue.canmakepayments()) {         println("iap enabled, loading")         var productid:nsset = nsset(object: "unlocklevelfourplease")         var request: skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>)         request.delegate = self         request.start()     } else {         println("please enable iaps")      } }   override func touchesbegan(touches: set<nsobject>, withevent event: uievent) {        var touch: uitouch = touches.first as! uitouch     var location = touch.locationinnode(self)     var node = self.nodeatpoint(location)       if node.name == "unlockleveltwobutton" {         callthis()          product in list {             var prodid = product.productidentifier             if(prodid == "unlockleveltwoplease") {                 p = product                 buyproduct()                 break;               }         }         runaction(menuaudioplayer)        }       if node.name == "unlocklevelthreebutton" {          callthis2()          product in list {             var prodid = product.productidentifier             if(prodid == "unlocklevelthreeplease") {                 p = product                 buyproduct()                 break;             }          }         runaction(menuaudioplayer)          }       if node.name == "unlocklevelfourbutton" {           callthis3()           product in list {             var prodid = product.productidentifier             if(prodid == "unlocklevelfourplease") {                 p = product                 buyproduct()                 break;              }         }         runaction(menuaudioplayer)       } 

from code looks haven't identified asynchronous mode of in-app purchases. whole process done in steps, various actors performing each step, , cannot described linear calls have listed above.

in-app purchase broadly made up of 3 distinct steps:

1 - getting products itunes store , displaying them on ui (store ui displays product titles, description, price in user-understandable way)

2 - providing mechanism user purchase products ui (ibactions enable "buy" action)

3 - handling post-purchase (handle successful purchase unlocking product, handle failed purchase displaying user-understandable error, , handle future restore non-consumable products must not purchased again per rules set apple)

this must do. if looking step step tutorial on how integrate iap - here own tutorial simplify wrote above.

if need more efficient solution, here video lecture series swift , objective c. accompanies code samples both.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -