Now I can just recognize WiFi/2G/3G/4G, but when the state is WiFi hotspot, AFNetworkReachabilityManager
or Reachability
also recognize the state as WiFi. Please help me to achieve this requirement, thanks a lot.
Asked
Active
Viewed 177 times
0

Remco Beugels
- 1,153
- 1
- 12
- 21
-
Possible duplicate of [detect hotspot enabling in iOS with private api's](https://stackoverflow.com/questions/31220371/detect-hotspot-enabling-in-ios-with-private-apis). This question does also include an answer which doesn't use private APIs. – Remco Beugels Nov 28 '17 at 08:53
-
@RemcoBeugels That question is about detecting whether a hotspot is enabled on the current phone. I think the OP is asking about detecting whether the current phone is connected to a hotspot (vs a proper Access Point). – Ewan Mellor Dec 05 '17 at 08:20
1 Answers
-2
I had found the right way:
- (void)startMonitorWifiChange {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
&onNotifyCallback,
CFSTR("com.apple.system.config.network_change"),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
}
static void onNotifyCallback(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo) {
if (CFStringCompare(name, CFSTR("com.apple.system.config.network_change"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
//TODO when wifi changed
[[BaiduLocationManager sharedManager].baiduLocationManager requestNetworkState];
}
else {
NBLog(@"intercepted %@", name);
}
}
- (void)stopMonitorWifiChange {
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
CFSTR("com.apple.system.config.network_change"),
NULL);
}

MAhipal Singh
- 4,745
- 1
- 42
- 57