Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

native.showAlert sometimes quits displaying on ios
Started by bangerlm Jan 15 2019 02:53 PM

1 reply to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

bangerlm

[GLOBAL: userInfoPane.html]
bangerlm
  • Enthusiast

  • 33 posts
  • Corona SDK

In my app I have a form with a native.newTextField that has a button beside it. If they click the button it opens up the plugin.qrscanner and scan a barcode, or they can type the value in the text field and the text box has a userInput event listener with the following code.

 

local function boxListener(event) 
  if ( event.phase == "began" ) then
 
  elseif ( event.phase == "ended" or event.phase == "submitted" ) then
    local message = {}
    message.isError = false
    message.message = event.target.text
    scene:scannerCallback(message)
 
   elseif ( event.phase == "editing" ) then
 
   end
end

 

where scannerCallback is the same function that the qrscanner returns its value to. It checks to see if the value is valid and displays a native.showAlert if it is not. The problem is that after using the app for a period of the time native.showAlert stops displaying, and not just for this case, but every time the showAlert is called subsequently in any part of the app, until you shut down the app completely and restart it. Anyone have any ideas on what could be causing this? I can't find any rhyme or reason on why it suddenly stops working.  This doesn't happen on the simulator, but happens when I build it to an iPhone 6. I haven't tried it on any other devices as this is the specific device my client will be using.

 

function scene:scannerCallback(event)
 
  if event.isError == false then
    local lotNumber = event.message 
   print("scannerCallback")
    if(lotNumber ~= scene.m_displayObjects["lotNumber"].text) then
      scene.m_nativeObjects["box"]:setText("")
      print("showing error the box is not part of hte lot")
      native.showAlert("Error", "The box is not part of the lot.", {"OK"})
    else
      scene.m_nativeObjects["box"]:setText(lotNumber)
    end
  else
    print('Error occured:', event.errorCode, event.errorMessage)
  end
end

 

 



[TOPIC: post.html]
#2

bangerlm

[GLOBAL: userInfoPane.html]
bangerlm
  • Enthusiast

  • 33 posts
  • Corona SDK

Discovered this was because I had two network.request calls that were sometimes coming back with responses that then displayed the native.showAlert.  If two native.showAlerts are trying to be shown at the same time iOS freaks and silently fails and won't show any future alerts.




[topic_controls]
[/topic_controls]