Hi, just looking for a bit of advice about if what I’m doing is ok?
I setting up an IAP for the first time and want to know if its ok to call it via a native.showAlert popup
I have the following code
function transactionCallback( event ) if event.transaction.state == "purchased" then myData.gameTypes = true -- Unlock new game modes native.showAlert("Thank you!", "Hope you enjoy the new game modes!", {"Okay"}) elseif event.transaction.state == "restored" then myData.gameTypes = true -- Unlock new game modes native.showAlert("Welcome Back!", "Thank you for coming back again!", {"Okay"}) elseif event.transaction.state == "refunded" then myData.gameTypes = false -- Lock game modes back up elseif event.transaction.state == "cancelled" then -- Do nothing elseif event.transaction.state == "failed" then -- Do nothing else print("WTF has happened???.") end store.finishTransaction( event.transaction ) end store.init(transactionCallback) local modeTouch = function( event ) if event.phase == "release" then audio.play( clickSound ) if myData.gameTypes == true then storyboard.gotoScene( "game2" ) else local function onComplete( event ) if "clicked" == event.action then local i = event.index if 1 == i then -- Buy - Unlock game modes and charge store.purchase( {"Product ID"}) elseif 2 == i then -- Restore - Unlock purchases if already bought store.restore() elseif 3 == i then -- Cancel - Do nothing, dialog will shut end end end local alert = native.showAlert( "Instant Access", "Unlock all the game modes", { "Buy", "Restore", "Cancel" }, onComplete ) end end end
I’m basically making it so that when the player hits the button assigned to the modeTouch function it checks to see if gameTypes is true, if not it opens an alert windows where the player can purchase, restore or cancel. If they purchase it takes them to a second window where they confirm their purchase.
Is it ok to do it this way??
I can’t see a problem doing it like this but just wanted to check
Thanks