Hey guys
I might be wrong but it seems that there is some kind of bug or delay in purchaseListener function, that lets me to buy nonconsumable product twice in debug test mode…
Here is my code:
function purchaseListener(product, event ) -- print("DO 1") if(product == "removeAds") then -- print("DO 2") --Give the user a message saying the purchase was successful removeAdsIcon:removeEventListener ( "tap", wasTapped ) removeAdsIcon:removeEventListener("tap", buyUnlock) removeAdsIcon.alpha = 0 adsYouPurchased.alpha = 1 adsYouPurchased:addEventListener("tap", wasTapped) --Save the inventory change iap.saveInventory() native.showAlert("Info", "Your purchase was successful", {"Okay"}) return true elseif(product == "buyLevel2") then -- print("DO 3") level2:removeEventListener("tap", buyUnlock) -- print("DO 5") level2:setSequence("blink") level2:play() iap.saveInventory() level2:addEventListener("tap", goSomewhere) native.showAlert("Info", "Your purchase was successful", {"Okay"}) end end buyUnlock=function(event) --Tell IAP to initiate a purchase iap.purchase(event.target.product, purchaseListener) end
Now what happens here:
-
removeAdsIcon is a png (display.newImageRect)
-
level2 is NOT a png, it is a Sprite (display.newSprite)
When I test above code in Windows Corona Simulator 2015.2731 (debug mode) it goes well for buying removeAdsIcon (i.e. you can click only once to remove Ads (because this line is executed: “removeAdsIcon:removeEventListener(“tap”, buyUnlock)” )
The problem is that you can click TWICE to buy level2 (I repeat level2 is a Sprite )
My question is, why “level2:removeEventListener(“tap”, buyUnlock)” line is executed only after two times clicking on level2 ?
1. So I click first time, and level2 native Text view pops up for buying level2 (I buy it and level2 starts to blink).
2. Second time when I click native Text view pops up for buying level2 (again!), and at the same time I go to level 2 (remember that it was opened/started to blink after first click on it - which is OK !) ?
Waiting your reply.
Many thanks.
Ivan