Open iOS 8 URL Settings

How to open settings using the UIApplication.sharedApplication () command

What URL should I go through?

I used UIApplicationOpenSettingsURLString, but it opens directly on the application settings page. but I would like for him to open the first level of the Settings app.

Or, even better, I would like to open it directly on the page where the user can enable the location services on his phone.

The codes below open directly on the application settings page.

UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!);
+4
source share
4 answers

: , , UIApplicationOpenSettingsURLString ( )

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

+3

UIRequiresPersistentWiFi YES Info.plist , , facebook, .

:

1: URL-, "" .

2:. "" , UIApplicationOpenSettingsURLString iOS 8.

, Facebook, "" , UIRequiresPersistentWiFi YES.

+2

( iOS8 ).

Swift:

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

Objective-C

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

( iOS8) .

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)!)
}
+1

Xamarin.iOS:

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

Source: https://habr.com/ru/post/1613153/


All Articles