简体   繁体   中英

iPhone- Open Settings from my application iOS 6

I know there are many questions related to this.

1) is it possible to open Settings App using openURL?

2) Opening the Settings app from another app

3) iOS Launching Settings -> Restrictions URL Scheme

I have followed these questions for reference but that does not solve my query. I know that using openURL method you can open Settings but that was valid for only iOS 5.0 - 5.0.1. In iOS 5.1 it was deprecated.

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]]; 

Still I have been seeing lot of Apps mainly location based which asks for user permission to turn on Location Services and takes directly to Location Services under Settings--> Privacy. The screenshot of an App, which is installed on iOS 6.1 running device, below shows that tapping on Settings take you to directly Location Services .

I tried to run code in my App but it is not working (I want to take user to Settings page to allow my app to access contact information directly from my App). If Apple has disabled URL Schemes for this how come many Apps are still using it?

在此输入图像描述

For apps that tie into services such as Location, the first time they request access the OS will throw out the alert with buttons that link to Settings. This isn't actioned by the app, but by the underlying security of the OS.

iOS 6 removed the ability to do this yourself as you mentioned.

You can open settings app programmatically in iOS8, but not in earlier versions of iOS.

In Swift:

UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString));

Swift 4:

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.openURL(url)
}

In Objective-C

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM