Open Wifi Settings by “prefs:root=WIFI” failed in iOS 10

后端 未结 7 1386
太阳男子
太阳男子 2020-12-09 09:18

I was using prefs:root=WIFI url scheme in my app with prefs entered in info.plist to open directly the iOS settings application in Wi-Fi settings and it was working great on

相关标签:
7条回答
  • 2020-12-09 09:59

    Just so it's explicit: Apple does not allow this. It's possible your app will make it through anyway, but this is the same as using any other undocumented API.

    Here is the full list of supported Apple URL schemes.

    Here's a thread where Apple confirms that "any Apple URL schemes that are not officially documented should be considered private API."

    0 讨论(0)
  • 2020-12-09 10:06

    try this for objective c in iOS 10

    NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
       [[UIApplication sharedApplication] openURL:url];
    } else {
       [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=WIFI"]];
    }
    
    0 讨论(0)
  • 2020-12-09 10:06

    This works fine on iOS 10,

    Go to Targets --> (Application) --> Info --> URL Types --> +

    In the URL Schemes write

    prefs

    Then Call,

    - (void)openWifiSettings
    {
        if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=WIFI"]]) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
        } else {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=WIFI"]];
        }
    }
    
    0 讨论(0)
  • 2020-12-09 10:08

    iOS 10, to open your apps settings:

    if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) {  
                    UIApplication.shared.openURL(settingsURL)
              }
    
    0 讨论(0)
  • 2020-12-09 10:10

    Using "App-Prefs:root" instead of "prefs:root"

    0 讨论(0)
  • 2020-12-09 10:13

    SWIFT 3.0:- working in iOS 10

    @IBAction func openWifiSetting(_ sender: AnyObject) {
        let url = URL(string: "App-Prefs:root=WIFI") //for WIFI setting app
        UIApplication.shared.openURL(url!)
    }
    
    0 讨论(0)
提交回复
热议问题