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 CTTelephonyNetworkInfo
has a property currentRadioAccessTechnology
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.