iOS BLE-如何使应用程序在后台保持活动状态? [英] iOS BLE - How to keep app active in the background?

查看:273
本文介绍了iOS BLE-如何使应用程序在后台保持活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种巧妙的方法来在iOS 6上保持BLE应用程序在后台运行,而又不会违反苹果的任何规则.我计划将电话用作外围设备,并使用另一个BLE电路作为中央设备.当用户使用地理围栏到达建筑物时,我的应用程序将自动打开.之后,iPhone将连接到它看到的第一个BLE中央设备(该设备将在其白名单中).然后,用户将能够在整个建筑物中移动,切换到不同的BLE节点".

I am trying to find a clever way to keep a BLE app active in the background on iOS 6, without breaking any of Apple's rules. I plan to use the phone as a peripheral device and another BLE circuit as the central. My app will automatically be opened when a user arrives to a building using geofencing. After that the iPhone will connect to the first BLE central device it sees (the device will be in its white list). The user will then be able to move throughout the building switching to different BLE "nodes".

我的问题是:当用户固定在办公桌旁时,该后台该怎么办,以使该应用不会由于内存资源而挂起?

My question is: What do I need to do in the background when a user is stationary at their desk so that the app does not get suspended due to memory resources?

我的想法基于此解决方案的一个单独问题:在仅有几个BLE节点"的区域中,可能(不定期)有10-50个用户,我在bluetooth.org上阅读了可以设置一个动态连接系统,基本上是通过所有用户旋转连接.

My idea is based on this solution for a separate problem: There could potentially (not regularly) be 10-50 users in an area with only a few BLE "nodes" and I read at bluetooth.org that I could setup a dynamic connection system, basically rotating connections through all the users.

我的想法是建立一个类似的动态系统,在该系统中,中央设备(不是iPhone)会定期(30-40分钟)断开设备的连接,然后iPhone将重新连接.

My idea is to setup a similar dynamic system where the central device (not the iPhone) disconnects the device on regular intervals (30-40 minutes) and then the iPhone will reconnect.

这是否可行?这违反iOS开发指南吗?我找不到任何明确的信息.我也曾在iOS开发者论坛上提问,但不幸的是,它不像该网站那样受欢迎.

Is this something that some feasible? Is this against the iOS development guidelines? I was unable to find anything explicit about this. I have also asked on the iOS developer forum, but unfortunately it is not as popular as this site.

提前谢谢!

推荐答案

Xcode->项目目标->功能->启用后台模式

Xcode -> Project target -> Capabilities -> Enable background mode

检查使用的蓝牙LE配件

Check Uses Bluetooth LE Accessories

功能

还要在.plist文件中启用以下密钥

Also enable the following key in .plist file

所需的背景模式

应用程序使用CoreBluetooth进行通信

App communicates using CoreBluetooth

Plist

这篇关于iOS BLE-如何使应用程序在后台保持活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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