iPhone 비행기 모드를 확인하는 방법은 무엇입니까?
문제
안녕 ,
비행기 모드가 켜져 있는지 아닌지를 확인하고 싶습니다. 어떻게 확인 하는가?
감사합니다 + 사용자가 WiFi 또는 GPRS 또는 Edge를 사용하고 있는지 확인하는 방법. 구별하는 방법 ??
해결책
사용자가 비행기 모드에있을 때 표시 알림을 원한다면 앱의 plist 파일에서 sbusesnetwork 속성을 활성화하는 것으로 충분합니다. 코드가 네트워크를 사용하는 경우 사용자는 비행기 모드를 자동으로 끄는 메시지가 표시됩니다.
예를 들어보십시오 이 게시물.
다른 팁
비행기 모드를 특별히 확인할 수 있는지 확실하지 않지만 도달 가능성 iPhone ADC 웹 사이트의 예를 통해 iPhone이 인터넷에 액세스 할 수 있는지 확인할 수 있습니다.
이것은 질문의 두 번째 부분 - 사용자가 어떤 유형의 네트워크에 있는지 (WiFi 또는 3g/edge)를 말하는 방법에 답변합니다. Apple의 도달 가능성 코드를 사용합니다. 앱 대의원에서 이것을 didfinishlaunchingwithoptions 메소드에 넣으십시오.
Reachability *curReach = [Reachability reachabilityWithHostName: @"www.apple.com"];
NetworkStatus netStatus = [curReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Status" message:@"Please note: Network access is required to retrieve images." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
break;
}
case ReachableViaWiFi:
case ReachableViaWWAN:
{
break;
}
}
SDK 3.0의 경우
(http://bbs.51pda.cn/simple/?t4861.html)
#import unistd.h
#include dlfcn.h
#include stdio.h
typedef int (*airType)();
static int (*real_air)() = NULL;
int main(int argc, char **argv)
{
int status = 0;
void *libHandle = dlopen("/System/Library/PrivateFrameworks/CoreTelephony.framework/CoreTelephony", RTLD_LAZY);
real_air = (airType)dlsym(libHandle, "CTPowerGetAirplaneMode");
if(! real_air)
{
printf("something wrong");
}
else
{
status = real_air();
}
printf("%d",status);
return status;
}
데비안 : ~# arm -apple -darwin9 -gcc -lobjc -bind_at_load -f "/system/library/privateframeworks"-framework coretelephony test.c -o 테스트
제휴하지 않습니다 StackOverflow