美文网首页
iOS 跳转进蓝牙开关页

iOS 跳转进蓝牙开关页

作者: 嗷大喵 | 来源:发表于2025-04-16 10:57 被阅读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}];

相关文章

网友评论

      本文标题:iOS 跳转进蓝牙开关页

      本文链接:https://www.haomeiwen.com/subject/qyfebjtx.html