1
votes

I need to open the bluetooth settings menu in IOS10 and above.But [[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"prefs:root=Bluetooth"]]; is not working in ios 10.

After exploring multiple document I got below link which provide code which will work properly. https://gist.github.com/johnny77221/bcaa5384a242b64bfd0b8a715f48e69f

But, Now I have question will app store accept this patch code or they will reject application.

Please help me to solve this issue.

Thanks in advance

2
it doesn't work anymore in iOS 10.Rok Jarc
maybe take a look at this and see if it helps useyourloaf.com/blog/openurl-deprecated-in-ios10yawnobleix
Can u please check " gist.github.com/johnny77221/bcaa5384a242b64bfd0b8a715f48e69f" this link and tell me using that code will app store allow to upload application or they will reject the application.Priyanka

2 Answers

2
votes

Swift 3.0:- Working in all iOS version upto iOS 10.2

let url = URL(string: "App-Prefs:root") //for system setting app

@IBAction func blutootheButtonTapped(_ sender: AnyObject) {
let url = URL(string: "App-Prefs:root=Bluetooth") //for bluetooth setting 
    let app = UIApplication.shared
    app.openURL(url!)
}
0
votes

As of iOS 10 "App-Prefs:root" should be used rather than "prefs:root". See below Objective C code. Tested this , code works fine but Apple may reject the app because of this.

NSString *settingsUrl= @"App-Prefs:root=Bluetooth";
if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:settingsUrl] options:@{} completionHandler:^(BOOL success) {
        NSLog(@"URL opened");
        }];
}