4
votes

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.

2
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]] this should open setting app !! in which ios version are you testing ? - Ketan Parmar
it open settings app but it entered the app specific settings page....i want it to enter Setting home page or if possible mobile data page - da32
I am saying that it should open setting app's home page!!! - Ketan Parmar
i'm testing in ios 8 and ios 9...it didn't open home page - da32

2 Answers

1
votes

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)")

        })
     }
0
votes

url types

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

Other path: iOS Launching Settings -> Restrictions URL Scheme