选择了wifi蜂窝数据后调用

2018-08-01  本文已影响7人  tivon_lee

有权限后去调用
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//...
self.networkStatus(application, didFinishLaunchingWithOptions: launchOptions)
//...
return true
}
func networkStatus(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) {
if #available(iOS 9.0, *) {
let cellularData = CTCellularData()
cellularData.cellularDataRestrictionDidUpdateNotifier = { (state) in
switch state {
case .restrictedStateUnknown:
break

            case .restricted:
                break
                
            case .notRestricted:
                self.todo()
                break
            }
        }
    }
    else {
        self.todo()
    }
}
上一篇下一篇

猜你喜欢

热点阅读