最近,我问了一个问题,关于如何访问iOS 13中新的蓝牙访问提示符中的回调-- NSBluetoothAlwaysUsageDescription。我甚至不确定我是否看到了蓝牙访问提示,除非蓝牙与旧的描述- NSBluetoothPeripheralUsageDescription关闭。
注册提示回调涉及实现CBCentralManager实例和注册UpdatedState事件处理程序。
现在,我想知道--当显示提示时,是否有确定的方法?
如果我们创建一个默认的Xamarin.Forms/Xamarin.iOS应用程序并将以下内容添加到它的Info.plist文件中-
<key>UIBackgroundModes</key>
<array>
<!--The app communicates with BLE peripherals using the Core Bluetooth framework.-->
<string>bluetooth-central</string>
<!--The app shares data using the Core Bluetooth framework.-->
<string>bluetooth-peripheral</string>
</array>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App would like to use bluetooth.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>App would like to use bluetooth.</string>新的蓝牙提示符似乎是总是显示在应用程序启动。作为开发人员,我们可以这样处理这个位置吗?
这就是我所说的“类似位置”的意思。类似地,如果将位置访问添加到plist文件中,如下面所示,则在应用程序启动时会出现提示。然而,,,这个提示符显示给用户的时间可以被操纵!
当我们希望显示提示符时,只需实例化LocationManager实例-
Manager = new LocationManager();
Manager.LocationUpdated += HandleLocationChanged;我们面临的问题是,即使没有初始化任何与蓝牙相关的实例/类/实现/等等,应用程序总是首先提示使用蓝牙。所以-
我们可以控制蓝牙访问提示何时以编程方式显示(比如位置)吗?
(如果有人好奇-访问回调的位置提示注册CLLocationManager.AuthorizationChanged事件)
类似地,这些是我们目前有的用于定位的plist条目。
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App would like to access location.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>App would like to access location.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App would like to access location.</string>发布于 2019-12-09 07:22:43
如果您检查CBCentralManager的源代码。您会发现它有一个构造函数。
public CBCentralManager(ICBCentralManagerDelegate centralDelegate, DispatchQueue queue, CBCentralInitOptions options);因此,在导入ShowPowerAlert时,可以将属性CBCentralManager设置为true。
CBCentralManager manager = new CBCentralManager(new xxxDelegate(),null,new CBCentralInitOptions() { ShowPowerAlert=true});初始化CentralManager时,如果没有打开蓝牙,则会弹出警报。
https://stackoverflow.com/questions/59217841
复制相似问题