ble ios 后台运行不间断扫描连接问题

poppin_zk 2016-03-04 02:11:21
在做一个BLE项目的时候,要求ios端app后台运行依然可以自动扫描和连接蓝牙外设。
1.已经在xxx-info.plist文件中, Required background modes , 加入下面两项:
App shares data using CoreBluetooth 和 App communicates using CoreBluetooth。
2.指定了要扫描的广播出来service UUID
结果:在app打开时正常扫描连接,按home键,app转到后台运行后,扫描中断,即无法后台持续扫描。
而且发现一个有趣的现象ble的 app在后台运行时扫描中断,但如果打开另一个利用蓝牙的app(例如LightBlue),我的ble的app好像被唤醒一样,开始正常扫描和连接蓝牙外设。
请问是什么原因??
...全文
4519 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyingjun_2006 2017-04-07
  • 打赏
  • 举报
回复
scanForPeripheralsWithServices:options: Language SwiftObjective-C SDKs iOS 5.0+ macOS 10.7+ tvOS 9.0+ On This Page Declaration Parameters Discussion Scans for peripherals that are advertising services. Declaration - (void)scanForPeripheralsWithServices:(NSArray<CBUUID *> *)serviceUUIDs options:(NSDictionary<NSString *,id> *)options; Parameters serviceUUIDs An array of CBUUID objects that the app is interested in. In this case, each CBUUID object represents the UUID of a service that a peripheral is advertising. options An optional dictionary specifying options to customize the scan. For available options, see Peripheral Scanning Options. Discussion You can provide an array of CBUUID objects—representing service UUIDs—in the serviceUUIDs parameter. When you do, the central manager returns only peripherals that advertise the services you specify (recommended). If the serviceUUIDs parameter is nil, all discovered peripherals are returned regardless of their supported services (not recommended). If the central manager is already scanning with different parameters, the provided parameters replace them. When the central manager object discovers a peripheral, it calls the centralManager:didDiscoverPeripheral:advertisementData:RSSI: method of its delegate object. Apps that have specified the bluetooth-central background mode are allowed to scan while in the background. That said, they must explicitly scan for one or more services by specifying them in the serviceUUIDs parameter. The CBCentralManager scan option is ignored while scanning in the background.
m0_37743817 2017-03-03
  • 打赏
  • 举报
回复
引用 12 楼 zhangzhuangtian 的回复:
[quote=引用 5 楼 zh_kun 的回复:] 1、指定扫描一个服务的uuid 2、background mode ①app后台运行扫描连接正常 ②app锁屏但是屏幕亮的时候扫描连接正常 但当屏幕黑了以后不能扫描连接!!!!!
请问楼主这个问题解决了么.我目前开发也碰到这个问题了.还请指教一下.[/quote] 请问楼主这个问题解决了么.我目前开发也碰到这个问题了.还请指教一下
qq_26665759 2017-01-19
  • 打赏
  • 举报
回复
大哥,我在弄ios ble有一个问题很纠结,app 正在使用,这个时候有一台外设连接上了,我并不知道有目标设备连进来了,如果一直扫描的话,就很费电,求正解
zhangzhuangtian 2017-01-16
  • 打赏
  • 举报
回复
引用 5 楼 zh_kun 的回复:
1、指定扫描一个服务的uuid 2、background mode ①app后台运行扫描连接正常 ②app锁屏但是屏幕亮的时候扫描连接正常 但当屏幕黑了以后不能扫描连接!!!!!
请问楼主这个问题解决了么.我目前开发也碰到这个问题了.还请指教一下.
qq_35934684 2016-12-12
  • 打赏
  • 举报
回复
楼主问题解决没,我的问题和你的相似,就是后台不能重连,前台没问题,在前台断开了自动重连。
qq_27956671 2016-08-24
  • 打赏
  • 举报
回复
这个问题是怎么解决的啊
sinat_35133222 2016-05-27
  • 打赏
  • 举报
回复
楼主问题解决了吗,求分享
lzplyc 2016-05-11
  • 打赏
  • 举报
回复
我也有这个需求,楼主解决了不
fl531003271 2016-04-26
  • 打赏
  • 举报
回复
这个问题解决没有......
jackeyhooy 2016-03-18
  • 打赏
  • 举报
回复
关于这个问题,你私信我,我给你详细讲。
poppin_zk 2016-03-18
  • 打赏
  • 举报
回复
1、指定扫描一个服务的uuid 2、background mode ①app后台运行扫描连接正常 ②app锁屏但是屏幕亮的时候扫描连接正常 但当屏幕黑了以后不能扫描连接!!!!!
poppin_zk 2016-03-14
  • 打赏
  • 举报
回复
没有解决呀!
AirZilong 2016-03-11
  • 打赏
  • 举报
回复
lin415804 2016-03-11
  • 打赏
  • 举报
回复
楼主问题解决没有
poppin_zk 2016-03-07
  • 打赏
  • 举报
回复
不要沉呀!!

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧