Detecting offline status

Please provide the following:

  1. SDK Version: Latest
  2. Platforms(Android/iOS/web/all): Android/iOS

I am trying to detect offline status on my application to enable offline playback. Currently I call the function below, CheckConnectivity using Network from ‘expo-network’, but it only seems to return true even when the phone is in airplane mode. If there is any way to test an application’s offline functionality before building that would be extremely useful to me as well as I’ve had to wait between builds to test and it is very time consuming.

    const CheckConnectivity = async () => {
        //Check if the internet is connected - just do a get request to pwt if it fails wifi is off
        let networkStatus = await Network.getNetworkStateAsync();
        if(networkStatus.isConnected)
        {
            await dispatch(courseActions.setWiFiStatus( true ));
            console.log("online...");

        }
        else 
        {
            await dispatch(courseActions.setWiFiStatus( false ));
            console.log("ofline...");
            //Route to offline screen
        }
    };

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.