Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to support low data mode in iOS 13?

"Low Data Mode" is introduced in iOS 13. See "Settings" section Apple's iOS 13 overview:

Low Data Mode

I couldn't find any developer documentation on this.

Is this something third party app developers can opt into, as suggested by MacRumors? Or is will it just suspend background activity when not connected to Wi-Fi, as suggested by AppleInsider?

like image 702
Tieme Avatar asked Jul 04 '19 10:07

Tieme


People also ask

How do I turn on LTE on iOS 13?

On your iPhone, go to Settings > Cellular > Cellular Data Options and tap Enable LTE or Settings > Mobile Data and tap Enable LTE.


2 Answers

To determine if iOS is currently in Low Data mode, you can use the Network library:

import Network // Put this on top of your class

let monitor = NWPathMonitor()

monitor.pathUpdateHandler = { path in

    if path.isConstrained {
        // Path uses an interface in Low Data Mode.
    }
    else if path.isExpensive {
        // Path uses an interface that is considered expensive, such as Cellular or a Personal Hotspot.
    }
}

monitor.start(queue: DispatchQueue.global(qos: .background))
like image 107
Ely Avatar answered Nov 11 '22 17:11

Ely


URLSession supports LowData mode in iOS 13.

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)

Check out Advances in Networking, Part 1 from WWDC 2019 from 16:00 for a demo and sample code. You can use Combine to make the code simpler, but this is not required.

like image 24
CrazyPro007 Avatar answered Nov 11 '22 16:11

CrazyPro007