Hello,
I am having an issue when chaining multiple alerts.
This code, after pressing “Yes” on the retry alert, the simulator crashes, when compiled to android, nothing happens (no crash, no action, nothing, like if the call back was never called, even if I check for clicked or cancelled events)
-- some button triggers this event local buttonPress = function(event) local webCallback = nil --forward declaration local alertId = nil local onCompletePopUp = function(event) if event.action == "clicked" then if event.index == 1 then alertId = native.showAlert("title", "loading..") network.request("some url", webCallback, some\_params) else -- some code end end end webCallback = function(event) native.cancelAlert(alertId) -- actually more code here depending on the response, but this is the part failing. native.showAlert("title", "retry?", {"Yes","No"}, onCompletePopUp) end alertId = native.showAlert("title", "loading..") network.request("some url", webCallback, some\_params) end
Now there is this other code, it works as expected on the simulator. But on android, the callback function “clearData” which is supposed to be called after the user presses ok on the alert, is called right after the “loading” alert dissapears, without user interaction.
So the user is moved to the next scene, with the second alert shown.
local function update(event) local updatingAlert = nil local callback = function(isError) local clearData = function(event) -- some code -- go to some scene. end native.cancelAlert(updatingAlert) if isError then native.showAlert("title", "SECOND ALERT", {"Ok"}, clearData) else native.showAlert("title", "SECOND ALERT", {"Ok"}, clearData) end end updatingAlert = native.showAlert("title", "please wait... FIRST ALERT") some\_function(callback) -- async function with a callback end
Any advice on what is wrong or if this a known bug would be great.
Perhaps using alerts as “loading screens” is a bad idea.