简体   繁体   English

iOS 应用程序的后台 BLE 扫描 State

[英]BLE Scanning in background State of iOS app

There is any API OR third party for BLE communication in iOS app background state..?I tried “Uses Bluetooth LE accessories”,”Background Processing”,”Background fetch” with these capabilities BL Scanning is working but Advertisement data packet decrease.In app foreground state advertisement data packet increase..how can I get maximum quantity of advertisement data packets.?在 iOS 应用程序后台 state 中存在任何用于 BLE 通信的 API 或第三方或第三方。应用前台 state 广告数据包增加..我怎样才能获得最大数量的广告数据包.? I am using service UUID for Scanning.我正在使用服务 UUID 进行扫描。

As Rob Napier said, scanning in the background state as aggressively as in the foreground state is impossible by design because the system has lower resources and is attempting to save power.正如 Rob Napier 所说,在后台扫描 state 与在前台 state 一样积极地扫描在设计上是不可能的,因为系统资源较少并试图节省电力。 This is detailed in Apple's Core Bluetooth Programming Guide:-这在 Apple 的核心蓝牙编程指南中有详细说明:-

For iOS apps, it is crucial to know whether your app is running in the foreground or the background.对于 iOS 应用程序,了解您的应用程序是在前台运行还是在后台运行至关重要。 An app must behave differently in the background than in the foreground, because system resources are more limited on iOS devices.应用程序在后台的行为必须与在前台的行为不同,因为系统资源在 iOS 设备上受到更多限制。

Although you can perform many Bluetooth-related tasks while your app is in the background, keep in mind that scanning for peripherals while your app is in the background operates differently than when your app is in the foreground.虽然您可以在应用程序处于后台时执行许多与蓝牙相关的任务,但请记住,当您的应用程序处于后台时扫描外围设备的操作与您的应用程序处于前台时不同。 In particular, when your app is scanning for device while in the background:特别是,当您的应用在后台扫描设备时:

  • The CBCentralManagerScanOptionAllowDuplicatesKey scan option key is ignored, and multiple discoveries of an advertising peripheral are coalesced into a single discovery event. CBCentralManagerScanOptionAllowDuplicatesKey 扫描选项键被忽略,广告外围设备的多个发现合并为单个发现事件。

  • If all apps that are scanning for peripherals are in the background, the interval at which your central device scans for advertising packets increases.如果正在扫描外围设备的所有应用程序都在后台,则中央设备扫描广告数据包的间隔会增加。 As a result, it may take longer to discover an advertising peripheral.因此,发现广告外围设备可能需要更长的时间。

These changes help minimize radio usage and improve the battery life on your iOS device.这些更改有助于最大限度地减少无线电使用并延长 iOS 设备的电池寿命。

You can find more information here:-您可以在这里找到更多信息:-

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

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