How do I know if cellular access for my iOS app is disabled?

后端 未结 6 1074
别那么骄傲
别那么骄傲 2020-11-29 04:21

I have an iOS app that makes some small network requests on app launch (resource updates, etc). If the user turns off cellular access for the app in iOS Settings, they get

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 04:55

    There are lots of frameworks out there that will give you the status of your network connectivity, and of course you can roll your own. I've found AFNetworking to be one of the best. It has a singleton class called AFNetworkReachabilityManager that abstracts some of the complexities for you. Specifically you'll want to look at the two boolean properties:

    reachableViaWWAN
    reachableViaWiFi 
    

    There is also a reachability changed status block that you can set:

    – setReachabilityStatusChangeBlock:
    

    AFNetworking Github

    AFNetworkReachabilityManager

提交回复
热议问题