I am building a react-native app that launches a series of network requests (both UDP, HTTP) when it receives a special kind of notification, or based on a delayed execution.
However it turns out that after the first or second call, it enqueues the calls, without making them. If I open the applications, the remaining network calls are made, and the process continues.
It's a normal issue given that there is a specific doc page inside Android documentation targeting this behaviour:
I have read and research over SO: https://stackoverflow.com/questions/40216992/best-place-to-make-network-calls, https://stackoverflow.com/questions/49048434/how-to-make-network-call-from-background-service but those methods did not work to bypass the obstacle. I can require the user to deactivate "battery optimisation" if required, but that did not work either.
I should mention that I am using React Native in order to handle the lifecycle and trigger the network calls, so they are running inside an Activity that is not in the background or when the phone is locked. I believe there should be ways moving things to a) a background thread or b) an Android service.
I really appreciate any response, experience or links that would help me address this problem.