iPhone active network type (2G, 3G, WiFi)

后端 未结 3 480
萌比男神i
萌比男神i 2020-12-13 08:10

Does anyone know how to determine the active network type at the specific moment: 2G, 3G or WiFi.

For example, at a specific moment there

3条回答
  •  粉色の甜心
    2020-12-13 08:26

    The SCNetworkReachability interface can help you with that. Basically, you create a so-called reachability reference and then call SCNetworkReachabilityGetFlags on it to get information about the connection.

    The returned flags include kSCNetworkReachabilityFlagsIsWWAN, which tells you whether you are connected via WiFi or the cell network. AFAIK it cannot be used to tell the difference between 2G and 3G, though.

    See Apple's Reachability sample app for an implementation. In most cases, you should be able to directly use the included Reachability class in your project.

提交回复
热议问题