简体   繁体   中英

How can I open bluetooth setting on button press in ios9?

I want to open bluetooth setting page on click of one button. Currently, it is opening General page.

I am doing following for that:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Bluetooth"]];

Now you can open only current app settings, sorry ..... https://developer.apple.com/library/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS8.html

You can on/off bluetooth by

BluetoothManager *manager = [BluetoothManager sharedInstance];
[manager setEnabled:![manager enabled]];   

Use this URL Scheme:

prefs:root=General&path=Bluetooth

Below is the code:

NSURL*url=[[NSURL alloc] initWithString:@"prefs:root=General&path=Bluetooth"];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url];
    }

This will work for opening General screen in Settings for bluetooth

PS: Don't forget to add URL Types in targets info.plist file as shown below:

网址类型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM