iOS13 - How to query if Low Data mode is turned on using Xamarin Essentials Connectivity library?

iOS 13 introduced a feature where the user can turn on Low Data Mode to save network bandwidth consumption. Xamarin Essentials provides a Connectivity NuGet package which helps in determining if the phone has internet access or not . With the introduction of Low Data Mode, there is a need to distinguish if the internet is available with low data mode enabled or not. As per the following enum xamarin.essentials.networkaccess, it has a value ConstrainedInternet 3 Limited internet access, but this value is not set when Low Data Mode is enabled on iOS13 when we query the static property Connectivity.NetworkAccess. This looks incorrect because the value always returns Internet instead of ConstrainedInternet.

Please let me know if this is an issue with the Connectivity NuGet package OR if there is a better way to query if the Low Data Mode is enabled or not on an iOS13 phone

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Try to use URLSession , it supports Low Data.

    Steps

    • Provide two different resources for high resolution and low resolution(low data mode)
    • If statusCode == 200 (low data mode is disabled in setting).
    • If error.networkAvailableReason == .constrained (low data mode is enable in settings)

    Refer https://stackoverflow.com/a/56988795/8187800.

  • srichinsrichin USMember

    Hi, @ColeX , Thanks for the response. As mentioned in the query, if we need to know whether WiFi or Mobile Data is turned on or not, we currently do not have to make any attempt to connect to some random URL but just use the Connectivity module and query the NetworkAccess. But the suggestion provided in StackOverflow forces unnecessary call while Low Data Mode is a toggle that is set on the phone. So just to find out the value of a setting on the phone, I think it is a bit of an overkill to try to make a call which would add complications because we then have to ensure we make a secure connection, trust the endpoint to ensure it is not a fake endpoint, TLS 1.2, etc. Is there a simpler and a straightforward way to determine without actually having to make an internet connection.

  • ColeXColeX Member, Xamarin Team Xamurai

    Is there a simpler and a straightforward way to determine without actually having to make an internet connection.

    No , there is no existing API to know if Low Data mode is on or not . You have to make a internet connection to test.

Sign In or Register to comment.