【问题标题】:Core Bluetooth framework is not sending data to iOS app when the app is in background当应用程序处于后台时,核心蓝牙框架不会向 iOS 应用程序发送数据
【发布时间】:2019-09-06 15:24:45
【问题描述】:

我已经构建了一个 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】:

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

    【讨论】:

    • 感谢您的回答。我已经启用了您所指的选项,但它没有帮助。这个问题并不总是发生,我在随机情况下遇到它。你能给出其他的想法吗?
    • 最常见的是用户强制退出应用。
    • 我在测试自己时发现了这个问题,并且应用程序没有被强制退出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-15
    相关资源
    最近更新 更多