Flutter iOS端BluetoothScan等蓝牙权限申请失败问题排查
解决Flutter Permission Handler iOS蓝牙权限问题
是的,iOS端必须在Info.plist中添加对应的蓝牙权限描述字段,否则bluetoothScan、bluetoothConnect、bluetoothAdvertise这些细分权限无法正常申请成功,这是iOS隐私权限管控的硬性要求。
需要添加的Info.plist配置项
在项目的ios/Runner/Info.plist文件中,添加以下键值对(描述内容需清晰说明权限用途,避免App审核不通过):
蓝牙扫描与连接权限:
<key>NSBluetoothAlwaysUsageDescription</key> <string>需要蓝牙权限来搜索和连接周边蓝牙设备</string> <key>NSBluetoothPeripheralUsageDescription</key> <string>需要蓝牙权限来搜索和连接周边蓝牙设备</string>注:
NSBluetoothPeripheralUsageDescription适配iOS 12及以下版本,NSBluetoothAlwaysUsageDescription对应iOS 13+,建议同时添加覆盖全版本。蓝牙广播权限:
针对bluetoothAdvertise,除上述字段外,需保证权限描述包含广播用途(可直接复用上述NSBluetoothAlwaysUsageDescription并补充说明):<key>NSBluetoothAlwaysUsageDescription</key> <string>需要蓝牙权限来搜索、连接周边设备,以及向周边设备发送广播数据</string>
额外注意事项
- 确保你的Permission Handler包为最新版本,旧版本可能对iOS蓝牙细分权限的支持存在缺陷。
- iOS 13+后蓝牙权限分为「始终允许」和「使用期间允许」,
bluetoothAdvertise通常需要「始终允许」权限,因此优先使用NSBluetoothAlwaysUsageDescription。 - 权限申请代码无需调整,但需确保
request()方法调用后,等待权限弹窗用户操作完成再判断权限状态。
内容的提问来源于stack exchange,提问作者Sudip Mahanta
相关产品推荐
相关产品推荐

