简体   繁体   中英

iOS BLE Scanning for AdvertisementData in background when the phone is in Sleep Mode

I'm trying to search if it is possible for iPhone to scan BLE device and read its advertisementData while it is in sleep mode.

For example, continuous scanning as long as it takes and then if a device changes its advertisementData the phone will wake up and fire a local notification. Meaning, the app is running in background mode for x period of time.

Is it possible? Because in android it is.

There are restrictions on peripheral scanning when your app is running in the background:

  • You must specify the service UUIDs you are interested in; you cannot use nil
  • The duplicate scan option key is not supported. This is probably what is preventing you from achieving your desired result

As the duplicates key is ignored in the background, if a peripheral has previously been discovered by your app then its discovery will not re-trigger the didDiscoverPeripheral delegate method until your app is re-started.

For long-term discovery you should also opt-in to state-restoration but that isn't needed for a simple test-case running under Xcode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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