Listen to second alert

I’m having trouble getting an alert triggered by another alert to work…

I’m building a power-up system so when my user clicks unlock it checks whether the user can afford the power-up or not, if not, the user gets an option to get coins.

The first alert shows: Unlock & Cancel

The second Alert shows: Get coins & Cancel

I’m able to show the second alert, but other than displaying in the screen it wont do anything.

I created the second alert like this:

getCoinsAlert = native.showAlert( "Game", "You don't have enough coins. Would you like to get some?", { "Get Coins", "Cancel" }, onGetCoins ) 

and the function attached is this:

local function onGetCoins( event ) print("Getting Coins!") if "clicked" == event.action then local i = event.index if 1 == i then storyboard.gameVars.totalCoins = storyboard.gameVars.totalCoins + 50000 myCoinsLabel.text= storyboard.gameVars.totalCoins print("Total Coins: "..storyboard.gameVars.totalCoins) elseif 2 == i then end end end

Clicking the Get Coins button won’t even print “Getting Coins!”

Any ideas?

There was a similar thread about this the other day.  On iOS the messages stack so that the most recent message is over top of the previous.  I think on Android, you only get the most recent one.   The native.systemAlert() was not really designed to deliver a queue of messages.  The best thing you can do is show the first one and setup a handler when they click okay and have that handler do the work to trigger the 2nd one, that way the first one has to be dismissed before the second one shows up.

There was a similar thread about this the other day.  On iOS the messages stack so that the most recent message is over top of the previous.  I think on Android, you only get the most recent one.   The native.systemAlert() was not really designed to deliver a queue of messages.  The best thing you can do is show the first one and setup a handler when they click okay and have that handler do the work to trigger the 2nd one, that way the first one has to be dismissed before the second one shows up.