iOS 10背景中的CoreBluetooth广告 [英] CoreBluetooth advertising in background on iOS 10

查看:113
本文介绍了iOS 10背景中的CoreBluetooth广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先:我有一台iPad Air 2和一台iPhone 7.为了进一步阅读,我们估计该应用程序处于活动状态,并且在iPad上以及在iPhone上以后台模式打开。该应用程序完全相同,即使使用相同的蓝牙服务UUID和相同的DataLocalNameKey。

First: I have an iPad Air 2, and an iPhone 7. For further reading we estimate that the app is active and open on iPad and in background mode on iPhone. The app is exactly the same, even with same Bluetooth Service UUIDs and same DataLocalNameKey.

我想写一个可以在后台宣传蓝牙服务的应用程序,并且能够发现这项服务(在背景中也是最佳的)。 ​​正如我已经阅读过的我无法使用苹果信标技术因为它只能在背景中接近扫描/通知信标(我测试过,工作正常)但不能做广告。所以我开始使用CoreBluetooth,如上面提到的SO答案所述,因为它可以在后台做广告。

I want to write an app that can advertise a bluetooth service in background and is able to discover this service (optimal in background too). As I already read I can't use apples beacon technology cause there it's only possible to get scanning/notified by beacons in near in background (I tested this, works fine) but not to advertise. So I started to use CoreBluetooth as described in the mentioned SO answer cause there it's possible to advertise in background.

我的应用程序调用 didDiscoverPeripheral 方法(后台应用程序),因此它检测到了iPad。 iPhone上CBPeripheralManager的 isAdvertising 属性为 true 。但是在iPad上没有调用 didDiscoverPeripheral 。我有点困惑。一个选择是我的iPad由于某些原因无法再检测到iPhone,或者我的iPhone正在撒谎而且它不是广告。

My app calls didDiscoverPeripheral method in CBCentralManagerDelegate on the iPhone (app in background), so it detected the iPad. The isAdvertising property of CBPeripheralManager on iPhone is true. But didDiscoverPeripheral is not called on iPad. I'm a little bit confused. One option is my iPad is not able to detect the iPhone anymore for some reasons or my iPhone is lying and it's not advertising.

所以我想我只是一点点有点愚蠢和google搜索CoreBluetooth调试应用程序。我找到了 Vicinity AltBeacon 。对于这两个应用程序,行为是相同的!如果你是广告应用程序的后台(按主页/睡眠按钮),浏览应用程序将无法再发现它。如果您打开应用程序的后台,它将立即发现它。两个应用程序都提到它可以在后台播放。

So i thought I'm just a little bit of dumb and googled for "CoreBluetooth debug apps". I found Vicinity and AltBeacon. And with both apps the behavior is the same! If you background (press home/sleep button) the advertising app, the browsing app is not able to discover it anymore. If you open the backgrounded the app it will instant discover it. Both apps mention that its possible with them to broadcast in background.

我做错了什么;这种行为有望吗?我误解了框架吗?你可以确认这种行为吗?

Am I doing something wrong; is this behavior expected? Did I misunderstood the framework? Can you confirm this behavior?

要确认这一点,最快的方法是安装 Vicinity (您必须将 NSBluetoothPeripheralUsageDescription 键添加到Info.plist)将一台设备设置为广播,然后按主页按钮。

To confirm this, the fastest way is to install Vicinity on two devices (you have to add the NSBluetoothPeripheralUsageDescription key to Info.plist) set one device to broadcast and press the home button.

推荐答案

这是ios 10.0中的一个错误。(1)和部分修复了ios 10.1

it was a bug in ios 10.0.(1) and partially fixed in ios 10.1

src: https://forums.developer .apple.com / thread / 51309

这篇关于iOS 10背景中的CoreBluetooth广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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