設置info.plist
在info.plist文件中設置Required background modes添加
- App communicates using CoreBluetooth (客戶端)
- App shares data using CoreBluetooth (服務端)
target - signing&Capabilities - background modes
檢查一下是否自動勾選了 如果沒有則手動添加并勾選
target - signing&Capabilities - background modes
- User Bluetooth LE accessories
- Acts as a Bluetooth LE

image.png
聲明方式:增加UIBackgroundModes 鍵,并增加包含下列字符串的array值。
? bluetooth-central— 客戶端
The app communicates with Bluetooth low energy peripherals
using the Core Bluetooth framework.
? bluetooth-peripheral— 服務端
The app shares data using the Core Bluetooth framework
當我們需要開發(fā)的藍牙 只是客戶端 例如連接掃描打印機在后臺讀寫的時候
只需要第一個bluetooth-central即可