da32
da32

Reputation: 743

Redirect to Settings root page in ios 8, 9 and 10

My question has been asked a lot of time and till now hasn't got a solution. I'm trying to open Mobile data page from app.

1) I've tried

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

In iOS 8 and iOS 9, instead of root page, it directly went to Settings/AppName page. This is not the behavior that I want. What I want is to enter Settings root page

2) as for iOS 10, the above method doesn't work. I've tried

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

but it doesn't work.

Is there any code that can satisfy both of the above. in iOS 8, 9 and 10, it will go to Settings root page (if possible, mobile data page). If there isn't any way, can provide link why it doesn't work.

UPDATE:

in ios 8 and 9, by using [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=GENERAL"]] i'm able to redirect to Settings Home page.

for ios 10.1.0 and below, using [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=MOBILE_DATA"]] will redirect to app specific page in Settings. but in the latest 10.1.1, it won't do anything.

I'm using Xcode 8.0.

Upvotes: 4

Views: 579

Answers (2)

Anand Kore
Anand Kore

Reputation: 1330

in iOS 10 they changed "prefs:" to "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)")

        })
     }

Upvotes: 1

Andrey Oshev
Andrey Oshev

Reputation: 855

url types

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

Other path: iOS Launching Settings -> Restrictions URL Scheme

Upvotes: 0

Related Questions