현재 연결이 3G, Edge 또는 WiFi인지 여부를 확인하고 알림을받을 수 있습니까? 또는 연결이 WiFi인지 여부를 확인하는 방법은 무엇입니까?연결 유형 (3G, Edge, Wifi, GPRS)이 변경되었다는 알림을 수신하는 방법
1
A
답변
3
당신은 구현 후 애플의 도달 가능성 클래스
http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html
를 사용해야합니다 당신은 대리인이를 사용할 수 있습니다
- (void) configureTextField: (Reachability*) curReach
{
NetworkStatus netStatus = [curReach currentReachabilityStatus];
BOOL connectionRequired= [curReach connectionRequired];
NSString* statusString= @"non";
switch (netStatus)
{
case NotReachable:
{
statusString = @"Access Not Available";
//Minor interface detail- connectionRequired may return yes, even when the host is unreachable. We cover that up here...
connectionRequired= NO;
break;
}
case ReachableViaWWAN:
{
statusString = @"Reachable WWAN";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cellular Data Detected" message:@"You are using Cellular data such as 3G or Edge. Downloading large amount of data may effect your cellular internet package costs. To avoid such extra cost kindly use Wifi."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
break;
}
case ReachableViaWiFi:
{
statusString= @"Reachable WiFi";
break;
}
}
if(connectionRequired)
{
statusString= [NSString stringWithFormat: @"%@, Connection Required", statusString];
}
NSLog(@"Network= %@",statusString);
if ([statusString isEqualToString:@"Access Not Available"]){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"It seems you are not connected to the internet, the app will try to load from the last cached data - assuming this data exist."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
//textField.text= statusString;
}
- (void) updateInterfaceWithReachability: (Reachability*) curReach
{
if(curReach == hostReach)
{
//[self configureTextField: remoteHostStatusField imageView: remoteHostIcon reachability: curReach];
// NetworkStatus netStatus = [curReach currentReachabilityStatus];
// BOOL connectionRequired= [curReach connectionRequired];
[self configureTextField:curReach];
}
}
1
예, 애플은 그것을 보여주는 예제 프로젝트가 있습니다. Reachability
및 here's 예.
관련 문제
- 1. Wifi vs. Edge/3G 및 componentsSeparatedByString (NSString)
- 2. 인터넷 연결 (GPRS/EDGE/3G) 켜기/끄기
- 3. 볼륨 첨부 알림을 수신하는 방법
- 4. WiFi 연결 해제 처리 방법
- 5. ipod wifi 속도 시뮬레이션 (eb 3G)
- 6. .NET에서 3G 인터넷 연결 감지
- 7. 3G 또는 Wifi 네트워크 복원 감지
- 8. 안드로이드 3G 연결
- 9. iPhone 3G 연결 사용
- 10. iphone XCode-Wifi 연결
- 11. 3G/Edge/GPRS IP 주소 및 지오 코딩
- 12. 3g/wifi 사이를 전환 할 때 기존 연결은 어떻게됩니까
- 13. Skype 그룹 채팅에서 빌드 알림을 수신하는 도구
- 14. 3G 또는 Wifi 대신 GPRS 연결을 강제로 수행하는 방법은 무엇입니까?
- 15. Windows Form없이 플러그 앤 플레이 장치 알림을 수신하는 방법
- 16. 포함보기의 하위보기에서 키를 누를 때 알림을 수신하는 방법
- 17. Windows Mobile 연결 유형
- 18. 모바일 Safari에서 WIFI 연결 감지
- 19. QT 응용 프로그램 --- WIFI 연결
- 20. 코코아를 통해 WIFI 네트워크에 연결
- 21. wifi 및 3g iphone 및 mac 앱 통신
- 22. AT 명령 - 다른 셀에 3G 연결
- 23. Compact Framework에서 3G 검사 및 연결
- 24. WiFi 액세스 포인트와의 연결 끊김을 감지합니다.
- 25. 네트워크 연결 대역폭 감지 (Android)
- 26. Visual Studio 코드 모델 이벤트를 수신하는 방법?
- 27. https 연결은 Wifi (wlan)에서 작동하지만 3G/GPRS (umts)에서는 작동하지 않습니다.
- 28. Silverlight 파일 유형 연결
- 29. Android : WiFi 신호 강도 모니터링 방법
- 30. iPhone에서 WiFi 신호를 확인하는 방법