问题描述
我想知道是否有可能通过使用设备作为外围设备的coreBluetooth通过coreBluetooth来宣传服务以及iBeacons的范围,这是否还在后台完成?
本质上,目的是确定信标范围,然后如果信标位于.Near或.Immediate范围之内,则将更新设备通告的服务的特征。
我可以很高兴地完成测距任务,尽管我已经找到了充当外围设备的设备的信息,但我认为我可以解决这个问题,但是由于后台功能的限制我一再停下来,我想知道这种类型的在我花大量时间尝试完成某些事情之前,这种情况是可能的,结果每个人都知道这是不可能的。我一般对Swift和iOS还是陌生的,所以花很多时间来做很多事情。任何建议将不胜感激。
谢谢
I'd like to know if its possible to advertise services through coreBluetooth with a device acting as a peripheral and also range for iBeacons, also accomplish both in the background?Essentially the purpose being to range for beacons and then if a beacon is within .Near or .Immediate range update the characteristics of a service advertised by the device.I can happily accomplish the ranging task, and although I've found information on device acting as a peripheral slim I think i can manage that, however having been stopped repeatedly by background functionality limitations I wanted to know if this type of scenario is possible before i spend lots of time trying to accomplish something which it turns out everyone knows is not possible. Im new to Swift and iOS in general so it takes me time to get much done. Any advice would be greatly appreciated.Thanks
推荐答案
这是可能的,尽管后台有限制。
This is possible, although there are restrictions in the background.
前景:
- 您所描述的完全可能。 iOS允许使用
CoreBluetooth
同时发布蓝牙LE服务的广告,而使用CoreLocation
进行iBeacon的广告。
- Exactly what you describe is possible. iOS allows simultaneous advertising of a Bluetooth LE service using
CoreBluetooth
while ranging for iBeacons usingCoreLocation
.
背景:
-
iOS使用
CoreLocation
的信标范围API限制后台信标扫描,仅在信标区域首次出现后 5秒检测到。您可以使用我写的博客文章。延长更长的时间需要在您的Info.plist中添加位置背景模式,这可能会使您的应用难以获得AppStore的批准。
iOS limits background beacon scanning using
CoreLocation
's beacon ranging APIs to only five seconds after a beacon region is first detected. You can extend this five seconds of scanning to up to three minutes using a technique in a blog post I wrote here. Extending for longer requires adding a location background mode to your Info.plist, which may make it harder to get your app approved for the AppStore.
在iOS上在后台投放蓝牙LE服务与在前台投放广告不同。它使用Apple专有技术将服务标识符折叠成一个较小的广告包,该广告包将在所有宣传Bluetooth LE服务的应用程序之间共享。这些非iOS蓝牙LE设备可能不容易发现:
Advertising of Bluetooth LE Services in the background on iOS does not work like advertising in the foreground. It uses an Apple proprietary technique to collapse the service identifiers into a smaller advertising packet that is shared across all apps advertising Bluetooth LE services. These may not be easily discoverable by non-iOS Bluetooth LE devices:
请参见蓝牙外围设备背景执行模式部分以获取更多信息。
See the The bluetooth-peripheral Background Execution Mode section here for more info.
这篇关于集成iBeacon和coreBluetooth外围设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!