連線成為 WIFI 或蜂窩網路時發出警報
- (void)reachabilityChanged:(NSNotification *)note {
Reachability* reachability = [note object];
NetworkStatus netStatus = [reachability currentReachabilityStatus];
switch (netStatus) {
case NotReachable:
NSLog(@"Network unavailable");
break;
case ReachableViaWWAN:
NSLog(@"Network is cellular");
break;
case ReachableViaWiFi:
NSLog(@"Network is WIFI");
break;
}
}