简体   繁体   English

iOS Corebluetooth广告和扫描时应用程序在后台

[英]iOS Corebluetooth advertising and scanning while app in the background

I am currently working on an iOS app that is running in the background that requires me to advertise and scan a device using Bluetooth 4.0. 我目前正在开发一个在后台运行的iOS应用程序,它需要我使用蓝牙4.0来宣传和扫描设备。

While learning about the Corebluetooth.framework, I found that iOS developers can set two kind of advertising data on the peripheral device. 在了解Corebluetooth.framework的同时,我发现iOS开发人员可以在外围设备上设置两种广告数据。

  1. local name of the device. 设备的本地名称。
  2. service UUIDs. 服务UUID。

I learned if the peripheral device is running in the background, however, local name will not be advertised. 我了解外围设备是否在后台运行,但是不会公布本地名称。 In addition, service UUIDs will be set to overflow area which the central device can only get by using active scanning. 此外,服务UUID将设置为溢出区域,中央设备只能通过主动扫描获得。 However, the active scanning can be running only in the foreground. 但是,主动扫描只能在前台运行。

At this point I have a question. 此时我有一个问题。

If both central and peripheral devices are running in the background, can a central device get service UUIDs which are set on the overflow area by a peripheral device? 如果中央设备和外围设备都在后台运行,中央设备是否可以获得外围设备在溢出区域设置的服务UUID? That is when both iOS applications are running in the background, is it possible to develop an app that each apps are advertising and scanning each other in the background? 那就是当两个iOS应用程序都在后台运行时,是否可以开发一个应用程序,每个应用程序都在后台进行广告宣传和扫描?

A backgrounded peripheral cannot be found by a backgrounded central exactly for the reasons you describe: 由于您描述的原因,背景中心无法找到背景外围设备:

  1. the peripheral does not advertise the services 外围设备不会宣传这些服务
  2. the central can scan only with service filtering (while backgrounded) 中央只能通过服务过滤进行扫描(背景时)

This has been an issue in iOS 6 and I haven't seen anyone being able to do it in iOS 7 until now either. 这是iOS 6中的一个问题,我还没有看到任何人能够在iOS 7中做到这一点。 (Further testing in progress.) (进一步测试正在进行中。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM