Pregunta

HI,

quiero verificar si el modo Avión está activado o no ... ¿cómo verificar eso?

gracias + cómo verificar que el usuario esté usando WIFI o GPRS O EDGE. ¿Cómo diferenciar?

¿Fue útil?

Solución

Si solo desea mostrar notificación, cuando el usuario está en modo avión, es suficiente para habilitar la propiedad SBUsesNetwork en el archivo plist de su aplicación. Cuando su código usa la red, se le solicita al usuario que desactive el modo Avión automáticamente.

Ver p. esta publicación .

Otros consejos

No estoy seguro de si puede verificar específicamente el modo avión, pero el accesibilidad del sitio web adc de iPhone le permite verificar si el iphone tiene acceso a Internet.

Esto responde a la segunda parte de la pregunta: cómo saber en qué tipo de red se encuentra el usuario (Wifi o 3g / edge). Utiliza el código de accesibilidad de Apple. Ponga esto en su método didFinishLaunchingWithOptions en el delegado de su aplicación:

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;
    }
}   

Para 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;
}
  

debian: ~ # arm-apple-darwin9-gcc -lobjc -bind_at_load   -F " / Sistema / Biblioteca / PrivateFrameworks " -framework CoreTelephony test.c -o prueba

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top