iOS 低功耗蓝牙 在后台长期运行的解决方案
2015-09-14 10:57
531 查看
最近一段在做低功耗蓝牙的项目, 有个需求是需要在后台长期运行蓝牙的连接 重连 数据传输等操作,但是苹果对后台运行的程序比较严格,网上现有的很多方案都不合适,后面在苹果文档上找到了答案,完美解决!
就不贴代码了,下面是摘要,看完就懂了:
Performing Long-Term Actions in the Background
Some apps may need to use the Core Bluetooth framework to perform long-term actions in the background. As an example, imagine you are developing a home security app for an iOS device that communicates with a door lock (equipped with Bluetooth low energy technology).The app and the lock interact to automatically lock the door when the user leaves home and unlock the door when the user returns—all while the app is in the background. When the user leaves home, the iOS device may eventually become out of range of the lock,
causing the connection to the lock to be lost. At this point, the app can simply call the
connectPeripheral:options:method
of the
CBCentralManagerclass,
and because connection requests do not time out, the iOS device will reconnect when the user returns home.
Now imagine that the user is away from home for a few days. If the app is terminated by the system while the user is away, the app will not be able to reconnect to the lock when the user returns home, and the user may not be able to unlock the door. For apps
like these, it is critical to be able to continue using Core Bluetooth to perform long-term actions, such as monitoring active and pending connections.
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- android通过蓝牙接收文件打开时无法自动选择合适的应用程序
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android提高之蓝牙隐藏API探秘
- Android编程之蓝牙测试实例
- Android提高之蓝牙传感应用实例
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器