Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if connection has been switched to 3G while app is in background in iOS?

Is it Possible for an app to know whether the connection has been switched from Wi-Fi to 3G While app is in background?The requirement is that download should happen on Wi-Fi Connection.The Check is done initialy but i need to confirm that download is happening on Wi-Fi and should be cancelled if the user has switched to 3G/4G while app is in Background.

like image 303
Jacob Davis Cherussery Avatar asked Mar 20 '23 19:03

Jacob Davis Cherussery


1 Answers

If you just want to make sure downloads only happen on WiFi, then you should set the allowsCellularAccess property of the NSURLSession's NSURLSessionConfiguration to NO.

No monitoring, cancelling or other tricks needed: that'll make sure the download never goes over the cellular connection.

like image 94
Matt Gibson Avatar answered Mar 22 '23 07:03

Matt Gibson