在iOS自定义键盘中使用时不支持iOS CoreBluetooth状态 [英] iOS CoreBluetooth state unsupported when using in iOS custom keyboard
问题描述
我想在iOS键盘扩展(自定义键盘)中使用 CoreBluetooth
API。但是,不支持 CBCentralManager
的状态。我使用的设备是iPhone6。它在容器应用程序内正常运行。这是否意味着 CoreBluetooth
API不能在键盘扩展名内使用?
I want to use CoreBluetooth
API within iOS keyboard extension (custom keyboard). However, the state for the CBCentralManager
is unsupported. The device I use is iPhone 6. It works fine inside the container app. Does this mean that the CoreBluetooth
API cannot be used inside the keyboard extension?
推荐答案
您需要在NSExtension> NSExtensionAttributes下的扩展程序的plist中将 RequestOpenAccess
设置为YES。
You will need to set RequestOpenAccess
to YES in your extension's plist under NSExtension > NSExtensionAttributes.
设置此项设为是将允许扩展访问网络资源。蓝牙被视为网络资源,因此当 RequestOpenAccess
为否时,您将获得 CBManagerStateUnsupported
。
Setting this to YES allows the extension to access network resources. Bluetooth is considered a network resource so you will get CBManagerStateUnsupported
when RequestOpenAccess
is NO.
这篇关于在iOS自定义键盘中使用时不支持iOS CoreBluetooth状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!