简体   繁体   中英

iOS how to detect cellular data is turned on when wifi is turned on at the same time

I want to use cellular data to connect the network priority.

So is there a way to detect cellular data's status when wifi is turned on?

You should be able to obtain the cellular data status via Core Telephony framework. The class CTTelephony​Network​Info has a property current​Radio​Access​Technology that'll tell you which type of cellular network you are registered to at the moment, eg, CTRadioAccessTechnologyLTE . You can find all possible values in the Constants Overview of Core Telephony .

let info = CTTelephonyNetworkInfo()
if info.currentRadioAccessTechnology != nil {
    print("Cellular Data available")
}

另一种可能的方法是将iOS 9.0+ CTCellularData接口与cellularDataRestrictionDidUpdateNotifier块一起使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM