GitHub user akravchukabto edited a discussion: XHR requests are canceled in 
cordova-ios after the screen is locked

Hi,
in our cordova ios app there is a case, when user can save the using **xhr 
request**.
In normal scenario when the Iphone screen is not locked after starting the save 
request - everything works fine.
But when the screen gets locked right after starting save request - request 
fails with error - **Failed to load resource: The network connection was lost**
I have made some research on this issue and found 
[https://stackoverflow.com/questions/43505618/failed-to-load-resource-the-network-connection-was-lost-safari](url)
It is said that **WKWebView has been "optimized" to not make network 
connections while screen is locked**
As far as I understand cordova-ios is using **WKWebView** so it may inherit 
this limitation.

1. Can you, please, clarify if this is expected behaviour for xhr requests to 
be canceled when the screen is locked on ios devices?
2. Are there any workarounds to deal with this issue - I mean, user starts save 
request, locks the screen, and request is completed successfully?

I have also tried using advanced http plugin 
[https://github.com/silkimen/cordova-plugin-advanced-http#readme](url) - the 
request is not canceled immediately, but when the time spent in background 
exceeds timeout - request is canceled by timeout.

The issue is observed on IOS platform only

Thank you for any help.

GitHub link: https://github.com/apache/cordova/discussions/459

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to