services español ios iphone gps settings

ios - español - Abra la aplicación de configuración desde otra aplicación mediante programación en iPhone



location services en español (6)

Aquí hay una versión de Swift2 que funcionó para mí, incluida una alerta que instruye al usuario sobre qué hacer cuando se abre la configuración.

func initLocationManager() { locationManager = CLLocationManager() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestAlwaysAuthorization() // If there isn''t a Lat/Lon then we need to see if we have access to location services // We are going to ask for permission to use location if the user hasn''t allowed it yet. let status = CLLocationManager.authorizationStatus() if(status == CLAuthorizationStatus.NotDetermined || status == CLAuthorizationStatus.Denied) { //println(locationManager) // check that locationManager is even avaiable. If so, then ask permission to use it if locationManager != nil { locationManager.requestAlwaysAuthorization() //open the settings to allow the user to select if they want to allow for location settings. let alert = UIAlertController(title: "I Can''t find you.", message: "To let my App figure out where you are on the map click ''Find Me'' and change your location to ''Always'' and come back to MyMobi.", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "No Thanks", style: UIAlertActionStyle.Default, handler:nil)) alert.addAction(UIAlertAction(title: "Find Me", style: UIAlertActionStyle.Default, handler: { (alert: UIAlertAction!) in UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!) })) self.presentViewController(alert, animated: true, completion: nil) } } }

Tengo que abrir la aplicación de configuración de mi aplicación si gps no está habilitado en iPhone. He usado el siguiente código. Funciona bien en el simulador iOS pero no funciona en iPhone. ¿Puedo saber si hay algún problema en este código?

if (![CLLocationManager locationServicesEnabled]) { int (*openApp)(CFStringRef, Boolean); void *hndl = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices"); openApp = (int(*)(CFStringRef, Boolean)) dlsym(hndl, "SBSLaunchApplicationWithIdentifier"); openApp(CFSTR("com.apple.Preferences"), FALSE); dlclose(hndl); }


Buenas noticias :

Puede abrir aplicaciones de configuración de forma programática como esta (solo funciona desde iOS8 en adelante).

Si está usando Swift 3.0:

UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!)

Si está utilizando Objective-C:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

Para otras versiones inferiores (menos de iOS8 ) no es posible abrir programáticamente la aplicación de configuración.


Como otros respondieron, no puedes abrir la Configuración desde tu aplicación.

Sin embargo, puedes resolver la situación, como lo he hecho:

Enviar un mensaje indicando que los servicios de ubicación deben estar habilitados para explicar por qué, y mostrar la ruta en ese mensaje:

"Configuración-> Privacidad-> LocationServices"


Hasta iOS 5.0, era posible abrir la settings través del URL schema , es decir,

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"My Settings URL"]];

Esto ha quedado obsoleto desde iOS 5.1 en adelante.


La apertura de aplicaciones de configuración mediante programación solo es posible desde iOS 8. Por lo tanto, use el siguiente código ...

if([CLLocationManager locationServicesEnabled]&& [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) { //...Location service is enabled } else { if([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) { UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [curr1 show]; } else { UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil]; curr2.tag=121; [curr2 show]; } } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 121 && buttonIndex == 1) { //code for opening settings app in iOS 8 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; } }


openURL quedó obsoleto en iOS10.0: utilice openURL: options: completionHandler en su lugar

let url = URL(string: UIApplicationOpenSettingsURLString)! UIApplication.shared.open(url, options: [:]) { success in }