当蓝牙设备在附近时,唤醒ios应用程序 [英] Wake up ios app when a bluetooth device is near by

查看:487
本文介绍了当蓝牙设备在附近时,唤醒ios应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在后台运行核心蓝牙以扫描设备。它工作正常,几乎停止,当我QUIT的应用程序手动。苹果文档声明该应用程序可以由外设有时唤醒,这可能会使其从暂停状态约10秒左右,做一些操作,然后回到挂起。

I am running core bluetooth in the background to scan for a device. It works fine, and pretty much stops when i QUIT the app manually. Apple docs state that the app can be woken up by the peripheral sometimes, and this may bring it from suspended state for about 10 seconds or so, do some operation and then go back to suspended.

资料来源:
https://developer.apple.com/library/IOs/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html

为了这个工作,外围设备是否需要已经连接,以唤醒应用程序?

For this to work, does the peripheral need to have already "connected" in order to wake up the app? Or can any new (undiscovered) peripheral wake up the app?

推荐答案

您的应用程序只会被唤醒外围事件/断开等)。但是,如果用户选择强制杀死您的应用程序(在iOS 7中向上滑动),您的应用程序将无法唤醒这些事件。 iOS系统会删除您,直到用户再次手动打开您的应用程序。

Your app will only be woken up for peripheral events (connection/disconnection etc). However, if a user chooses to force kill your app (swiping up in iOS 7), your app will not wake up for these events. The iOS system will remove you until the user manually opens your app once more.

为了订阅这些外设唤醒事件,您需要传入一个NSDictionary启动管理器时适当的恢复选项。详细信息请参见上面的问题链接。

In order to subscribe to these peripheral wake up events, you need to pass in an NSDictionary with the appropriate restoration options when initing your manager. The exact details are provided in the link you put in your question above.

至于最后一个问题:不,扫描,然后找到一些外围设备不会在后台唤醒您的应用程序。它仅适用于预先指定的外围设备。

And as for your last question: NO, scanning and then finding some peripheral will not wake your app up in the background. It is only applicable for pre-specified peripherals.

这篇关于当蓝牙设备在附近时,唤醒ios应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆