iOS 跳转进蓝牙开关页

2025-04-16  本文已影响0人  嗷大喵
if let url = URL(string: UIApplication.openSettingsURLString),
   UIApplication.shared.canOpenURL(url) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

上面代码只能打开 App 的设置页,无法直接进入到蓝牙的开关开启页。

当 iOS控制中心的蓝牙开关关闭后(非蓝牙权限开关),可以用下面代码直接打开蓝牙开关的页面。

[[CBCentralManager alloc] initWithDelegate:self
                                         queue:nil
                                       options:@{CBCentralManagerOptionShowPowerAlertKey: @1}];
上一篇 下一篇

猜你喜欢

热点阅读