Redirect to the root settings page in ios 8, 9 and 10

My question was asked a lot of time and still have not received a solution. I am trying to open a mobile data page from an application.

1) I tried

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

In iOS 8 and iOS 9instead root pagehe went directly to the page Settings/AppName. This is not the behavior I want. I want to enter the root settings page

2), as for iOS 10, the above method does not work. I tried

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil] 

but that will not work.

Is there any code that can satisfy both of the above. at iOS8, 9 and 10, he will go to the Settings page (if possible, the mobile data page). If not, you can specify the link why it does not work.

UPDATE:

ios 8 9, [[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "prefs: root = GENERAL" ]] .

ios 10.1.0 , [[UIApplication sharedApplication] openURL: [NSURL URLWithString: @ "prefs: root = MOBILE_DATA" ]] . 10.1.1 .

Xcode 8.0.

+4
2

iOS 10 "prefs:" "App-Prefs:"

    guard let profileUrl = URL(string: "App-    
     Prefs:root=General") else {
        return
    }

     if UIApplication.shared.canOpenURL(profileUrl) {

     UIApplication.shared.open(profileUrl, completionHandler: { (success) in

        print(" Profile Settings opened: \(success)")

        })
     }
+1

url types

UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=General")!)

: iOS → URL-

0

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


All Articles