Reputation: 195
I included a "Remove Ads" option in my app. I bought it in sandbox mode once, but I need to reset it for testing. It needs to reset so when I try to buy it again it won't restore for free.
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
println("add payment")
for transactions:AnyObject in transactions {
var trans = transactions as! SKPaymentTransaction
println(trans.error)
switch trans.transactionState{
case .Purchased:
println("buy, ok unlock iad here")
println(p.productIdentifier)
let prodID = p.productIdentifier as String
switch prodID {
case "removeAds":
println("remove ads")
removeAds()
break;
default:
println("IAP not set up")
}
case .Failed:
println("buy error")
queue.finishTransaction(trans)
break;
default:
println("default")
break;
}
}
}
func removeAds(){
noAdsButton.alpha = 0.0
adsOk = false
adsOkDefault.setBool(false, forKey: "adsOk")
println("REMOVE THE ADS")
}
I am using StoreKit.
Upvotes: 2
Views: 5921
Reputation: 885
To test your IAP over and over during initial debugging, the easiest way is to switch your non-consumable IAP to consumable temporarily. Then you can debug it by just buying it over and over. Once you have gotten rid of most bugs you can switch it back to non-consumable. It will become harder to test then because you need to create a new test user each time. There is a longer writeup on this issue here:
Clearing purchases from IOS in-app purchase sandbox for a test user
Upvotes: 3