有权限后去调用
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()
}
}
网友评论