swift - Will my app get rejected if the user has to close and open the app to unlock the in app purchase? -


sorry code want right. have 3 different in app purchases , code in gameviewcontroller. called functions in viewdidload() function. see wrong code?

edit:

override func viewdidload() {   super.viewdidload()   callthis()   callthis2()   callthis3() }      func callthis() {   if(skpaymentqueue.canmakepayments()) {     println("iap enabled, loading")     var productid:nsset = nsset(object: "unlockleveltwo")     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:  "unlocklevelthree")     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: "unlockeverything")     var request: skproductsrequest = skproductsrequest(productidentifiers: productid set<nsobject>)     request.delegate = self     request.start()   } else {     println("please enable iaps")   } }  func restorepurchases() {   skpaymentqueue.defaultqueue().restorecompletedtransactions()   skpaymentqueue.defaultqueue().addtransactionobserver(self)   println("can't make purchases") }  var list = [skproduct]() var p = skproduct()  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!) {   var myproduct = response.products    product in myproduct {     println("product added")     println(product.productidentifier)     println(product.localizedtitle)     println(product.localizeddescription)     println(product.price)      list.append(product as! skproduct)   }   }  func request(request: skrequest!, didfailwitherror error: nserror!) {   println("error fetching product info") }  func paymentqueue(queue: skpaymentqueue!, updatedtransactions transactions: [anyobject]!) {   println("received payment transaction response apple");   transaction:anyobject in transactions {     var trans = transaction as! skpaymenttransaction     println(trans.error)     switch trans.transactionstate {     case .purchased, .restored:       let prodid = trans.payment.productidentifier string       switch prodid {       case "unlockleveltwo":         println("unlocksleveltwo")         nsuserdefaults().setbool(true, forkey: "leavel2")         gamescene.unlockleveltwoplease()       case "unlocklevelthree":         println("unlocklevelthree")         nsuserdefaults().setbool(true, forkey: "leavel3")         gamescene.unlocklevelthreeplease()       case "unlockeverything":         println("unlockeverything")         nsuserdefaults().setbool(true, forkey: "leavel2")         gamescene.unlockleveltwoplease()         nsuserdefaults().setbool(true, forkey: "leavel3")         gamescene.unlocklevelthreeplease()         defaults.setbool(true , forkey: "removeadspurchased")       default:         println("unlockseverything")       }       queue.finishtransaction(trans)       break;     case .failed:       println("purchased failed");       queue.finishtransaction(trans)       break;     default:       println("default")       break;     }   } }  func finishtransaction(trans:skpaymenttransaction) {   println("finish trans")   skpaymentqueue.defaultqueue().finishtransaction(trans) }  func paymentqueue(queue: skpaymentqueue!, removedtransactions transactions: [anyobject]!) {   println("remove trans"); } 

then in gamescene.swift file this:

if node.name == "unlockleveltwobutton" {   product in viewcontroller.list {     var prodid = product.productidentifier     if(prodid == "unlockleveltwo") {       viewcontroller.p = product       viewcontroller.buyproduct()       break;     }   }   runaction(menuaudioplayer) } if node.name == "unlocklevelthreebutton" {   product in viewcontroller.list {     var prodid = product.productidentifier     if(prodid == "unlocklevelthree") {       viewcontroller.p = product       viewcontroller.buyproduct()       break;     }   }   runaction(menuaudioplayer) } if node.name == "specialdeal" {   product in viewcontroller.list {     var prodid = product.productidentifier     if(prodid == "unlockeverything") {       viewcontroller.p = product       viewcontroller.buyproduct()       break;     }   }   runaction(menuaudioplayer) } 


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 -