Locked out of Webview when starting with no internet connection

I use webviews in my app, but when I start my app with a bad internet connection I cannot use webviews without error until I restart the app, regardless of my connection at the time. I use the following code:

[lua]

local function webListener( event )
    if event.url then
        print( "You are visiting: " … event.url )
    end

    if event.type then
        print( "The event.type is " … event.type ) – print the type of request
    end

    if event.errorCode then
        native.showAlert( “Error!”, event.errorCode … “: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again.”, { “OK” }, closePress )
    end
end

local webView = native.newWebView( display.contentCenterX, TRUE_TOP + 80, TRUE_WIDTH, TRUE_HEIGHT - 80)
webView.anchorY = 0
    
webView:addEventListener( “urlRequest”, webListener )
webView:request( URL )

[/lua]

I receive the following error:

“-1002: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again.”

To reproduce this error, I simply have to turn on airplane mode on my phone, open the app, turn off airplane mode, and try to open any webview.

I have also checked the value of “network.canDetectNetworkStatusChanges,” which is “true.”

The below thread shows some methods to check for network status independent of that network. call. These methods might be useful just before you open the webView.

https://forums.coronalabs.com/topic/33356-check-for-internet-connection/

I have changed my code so that the alert reads as follows:

[lua]

native.showAlert( “Error!”, event.errorCode … ": This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again. " … tostring(json.encode(network.getConnectionStatus())) … URL, { “OK” }, closePress )
[/lua]

I receive the following:

“-1022: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again. {“isMobile”:false,“isConnected”:true}<myURL>”

I believe you’re seeing that error from the network.getConnectionStatus() API, which is undocumented (rationale for this can be found here). However, my thought was, if you’re already checking for an internet connection, and you know you don’t have one, then using a network. call seems redundant, because it will always fail?

It’s of course possible that I’m completely missing something.

The below thread shows some methods to check for network status independent of that network. call. These methods might be useful just before you open the webView.

https://forums.coronalabs.com/topic/33356-check-for-internet-connection/

I have changed my code so that the alert reads as follows:

[lua]

native.showAlert( “Error!”, event.errorCode … ": This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again. " … tostring(json.encode(network.getConnectionStatus())) … URL, { “OK” }, closePress )
[/lua]

I receive the following:

“-1022: This feature requires an internet connection. There was an issue connecting to the internet. Please make sure that you are connected and try again. {“isMobile”:false,“isConnected”:true}<myURL>”

I believe you’re seeing that error from the network.getConnectionStatus() API, which is undocumented (rationale for this can be found here). However, my thought was, if you’re already checking for an internet connection, and you know you don’t have one, then using a network. call seems redundant, because it will always fail?

It’s of course possible that I’m completely missing something.