ios - CoreBluetooth 后台执行 10 秒?

标签 ios objective-c core-bluetooth

因为苹果文档关于 this point 的内容相当模糊:

 Upon being woken up, an app has around 10 seconds to complete a task

这是否意味着应用程序将在 10 秒后返回到“暂停”状态?从理论上讲,是否有可能在这 10 秒后“强制”应用程序保持清醒状态? (私有(private)应用程序)。

在我的例子中,设备将连接到汽车。

最佳答案

Does this mean that after 10 sec the app will go back to its "suspended" state ?

如果你仔细阅读:

Upon being woken up, the app has around 10 seconds to process the data. Ideally, it should process the data as fast as possible and allow itself to be suspended again. However, if more time is needed, the app can use the beginBackgroundTaskWithExpirationHandler: method to request additional time; it should do so only when absolutely necessary, though.

应用程序通常通过后台模式(如位置服务、音频、推送通知等)唤醒,对于某些模式(如位置服务),它会保持唤醒状态,直到捕获位置数据,而对于某些模式,它不会保持唤醒状态很多时间像推送通知。所以这取决于正在执行的任务。对于蓝牙,如果它与另一个蓝牙设备连接,那么它将保持唤醒状态。

Theoretically, is it possible to "force" the app to stay awake after these 10 sec ? (private app).

是的,这是可能的。

Each of the preceding modes lets the system know that your app should be woken up or launched at appropriate times to respond to relevant events. For example, an app that begins playing music and then moves to the background still needs execution time to fill the audio output buffers. Enabling the Audio mode tells the system frameworks that they should continue to make the necessary callbacks to the app at appropriate intervals. If the app does not select this mode, any audio being played or recorded by the app stops when the app moves to the background.

注意:如果您的私有(private)应用程序需要它,那么您可以查看此 here .如果您添加解决方案并申请应用商店,您的应用将被拒绝。

关于ios - CoreBluetooth 后台执行 10 秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38968325/

相关文章:

ios - 字符串转换为大整数值

ios - 如何在 NSUserDefaults 中存储和加载 backgroundColor

ios - Reactive Cocoa - 以编程方式设置文本时,不会调用 UITextView 的 rac_textSignal

ios - 当 BLE 设备不再可见时处理

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

ios - Xcode 没有显示最新版本的 iOS?

ios - Xcode 8.1 架构 x86_64 错误的 undefined symbol

objective-c - 如何将对象从 NSDictionary 插入到 NSMutable 数组

ios - Facebook 在 iOS 上登录错误的应用程序

ios - 如何在 iOS 中查找蓝牙音频设备