gpt4 book ai didi

iOS 在未运行状态下从 BLE 获取数据

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:00:07 24 4
gpt4 key购买 nike

我在前台和后台状态下成功地从 BLE 获取数据。并且还调用了核心蓝牙框架各自的委托(delegate)方法。

用户强制退出应用程序后,我想要来自 BLE 设备的数据。是否可以在未运行状态下从 BLE 获取数据?或者有没有像iBeacon一样在非运行状态下调用的方法?

最佳答案

我认为除非使用 iBeacon BLE 设备,否则这是不可能的。如 Understanding When Your App Gets Launched into the Background 中所述部分:

Apps that support background execution may be relaunched by thesystem to handle incoming events. If an app is terminated for anyreason other than the user force quitting it, the system launches theapp when one of the following events happens:

For Bluetooth apps:

  • An app acting in the central role receives datafrom a connected peripheral.
  • An app acting in the peripheral rolereceives commands from a connected central.

In most cases, the system does not relaunch apps after they are forcequit by the user. One exception is location apps, which in iOS 8 andlater are relaunched after being force quit by the user. In othercases, though, the user must launch the app explicitly or reboot thedevice before the app can be launched automatically into thebackground by the system. When password protection is enabled on the device, the system does not launch an app in the background before the user first unlocks the device.

所以当应用程序被用户强制退出,而不是被系统强制退出时,这意味着用户不希望该应用程序在后台运行,并且该应用程序不会重新启动,也不会调用委托(delegate).

但如果应用程序被系统杀死,iOS 将在调用委托(delegate)时再次唤醒它。

关于iOS 在未运行状态下从 BLE 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54103360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com