现在检查CBPeripheralManager.authorizationStatus(),因为它已被弃用 [英] Checking CBPeripheralManager.authorizationStatus() now that it is deprecated

查看:271
本文介绍了现在检查CBPeripheralManager.authorizationStatus(),因为它已被弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CBPeripheralManager.authorizationStatus() CBPeripheralManagerAuthorizationStatus 。检查用户现在是否已授予在后台使用蓝牙权限的正确方法是什么?

CBPeripheralManager.authorizationStatus() and CBPeripheralManagerAuthorizationStatus are deprecated based on apple docs. What is the proper way of checking whether user has granted permission to use bluetooth in background now?

CBPeripheralManagerDelegate 具有 peripheralManagerDidUpdateState ,但无论用户是否授予许可,都不会返回未经授权的,而只会返回 poweredOn poweredOff

CBPeripheralManagerDelegate has peripheralManagerDidUpdateState but that never returns unauthorized regardless of whether user granted the permission or not, instead it only returns poweredOn or poweredOff

推荐答案

CBCentralManager CBPeripheralManager 继承自 CBManager

CBCentralManager and CBPeripheralManager inherit from CBManager.

从iOS 13开始, CBManager 有一个 授权 属性。您可以检查 .allowedAlways

As of iOS 13, CBManager has an authorization property. You can check this for .allowedAlways.

如果#available(iOS,可以使用 13.0,*)有条件地在iOS 13及更高版本上使用授权

You can use if #available(iOS 13.0, *) to conditionally use authorization on iOS 13 and later

这篇关于现在检查CBPeripheralManager.authorizationStatus(),因为它已被弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆