JayVDiyk
JayVDiyk

Reputation: 4487

Open Settings iOS 8 URL

How do we open Settings using the UIApplication.sharedApplication()

What URL should I pass in?

I used the UIApplicationOpenSettingsURLString but it opens directly to the Application specific Settings page. but I would like to have it open the first level of the Settings app.

Or even better, I would like it to open directly to the page where user can enable the Location Services on their phone.

the codes below opens directly to the Application specific Settings page.

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

Upvotes: 5

Views: 1915

Answers (4)

x4h1d
x4h1d

Reputation: 6092

For Xamarin.iOS developers:

UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));

Upvotes: 0

user3432164
user3432164

Reputation:

You can use UIRequiresPersistentWiFi to YES in your Info.plist files and create alertview like facebook the user launches your app without a network connection.

To summarize the discussion here:

Step 1: There is no URL you can use to get to the root level of the Settings app.

Step 2: You can send the user to your app's section of the Settings app using UIApplicationOpenSettingsURLString in iOS 8.

Your app can display the same alert as Facebook, which does open the root level of the Settings app, by setting UIRequiresPersistentWiFi to YES.

Upvotes: 2

Anbu.Karthik
Anbu.Karthik

Reputation: 82759

the answer to this questions is NO, we can't open direct Location page ,but we can open UIApplicationOpenSettingsURLString (settings page)

try this

if let appSettings = NSURL(string: UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(appSettings)
}
else
{
 // your URL is invalid
}

for additional information

Upvotes: 4

Mehul
Mehul

Reputation: 3178

You can open settings apps programmatically try this(works only from iOS8 onwards).

If you are using Swift:

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

If you are using Objective-C

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

For other lower versions(less than iOS8) its not possible to programatically open settings app.

Obj C:

- (void)openSettings
{
    BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);

    if (canOpenSettings) {
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        [[UIApplication sharedApplication] openURL:url];
    }
}

Swift:

func openSettings() {
    UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
}

Upvotes: 1

Related Questions