Reputation: 103
My React Native (Android) application sends requests to the server when some events are triggered. But when I lock phone screen and in a few minutes event is triggered, app try to send request, but it fails. I tried fetch
(error Network request failed
) and XMLHttpRequest
.
On some devices it works fine and I can't understand it depends on Android version or on device model.
Why does it happen and why on some (not all) devices? How can I fix it? Thanks!
Upvotes: 2
Views: 836
Reputation: 4705
Hello issue not because of react-native development but as per android guideline,
Whenever device in Doze
mode you can not access network or network resource directly for that you need to start some foreground service in your application or we can say foreground service, Actually, I don't know much about how to create and start foreground service in react-native, But maybe this word help you, Here also official document regarding doze
mode
https://developer.android.com/training/monitoring-device-state/doze-standby
Upvotes: 4