当应用程序处于后台时,核心蓝牙框架不会向iOS应用程序发送数据

问题描述 投票:0回答:1

我已经构建了一个iOS应用程序,它使用蓝牙低功耗(BLE)(一种核心蓝牙框架)与设备交换数据。

当应用程序处于后台时,即使设备已将数据发送到iPhone,BLE框架也不会将此数据发送到应用程序。

当应用程序到达前台时,它会收到应用程序处于后台时发送的所有数据。这意味着iPhone的蓝牙层接收到数据,但它只是存储数据并在应用程序到达前台时传送到应用程序。

这并不总是问题。这是以随机顺序发生的。

// application went to background 
2019/04/13 11:54:38:174  BLEManager# applicationDidEnterBackground
2019/04/13 11:54:38:176  BLEBackgroundTaskManager# applicationDidEnterBackground


// application receives data when it comes to foreground although this data was sent from device at 11:54:40:256
2019/04/13 12:39:36:149  CentralManager# Value received is <02>

预期的结果是,在收到数据时将调用didUpdateValueForCharacteristic,但是当应用程序处于后台时,将不会调用此API。当应用程序到达前台时,将调用此API。

ios background bluetooth-lowenergy core-bluetooth data-transfer
1个回答
0
投票

这通常意味着您没有在后台模式中添加“使用蓝牙LE附件”功能。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.