We have a cordova application, in this cordova application we want to provide a button for the app to go offline.
What is meant by offline is when the user clicks on the button the app thinks that there is no WiFi or cellular data. And any http requests going from the app will not be able to reach the server. This is required for both iOS and Android as well.
Is there any way to make the app think that it is offline?
Also, yes we can use a variable to keep track of network connectivity
and not send http requests if the variable is true, however we have no control of http requests
being sent by some libraries that are being used. We want the app to genuinely think that it is in offline status (like if data and WiFi is offed then).
Any suggestions are much appreciated also.
Edit:
There seems to be a duplicate question here
Latest update on enabling and disabling mobile data programmatically
However this question is for Android only and this question is for both Android and iOS and the accepted answer seems only for rooted devices which is not an option here, also this is for a Cordova application however not sure that makes much of a difference here though.