iOS 7 Core Bluetooth Peripheral running in background

jpcoder

What I want is for my iOS device to be advertising a Bluetooth LE service all the time, even when the app isn't running, so that I can have another iOS device scan for it and find it. I have followed Apple's backgrounding instructions here:

https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/PerformingCommonPeripheralRoleTasks/PerformingCommonPeripheralRoleTasks.html#//apple_ref/doc/uid/TP40013257-CH4-SW1.

I can get it to advertise in the foreground ok and sometimes in the background but it doesn't stay advertising all the time. If you have it setup to run in the background, shouldn't it start advertising even after a device restart, just like background location services automatically start working after a restart? Are their limitations to the backgrounding that are not listed (or hard to find) in Apple's docs? Does anyone have an example of a Core Bluetooth Peripheral advertising correctly in the background?

Thanks...

allprog

Background advertisement is possible if you add the bluetooth-peripheral backgrounding mode to the app's plist. Once you do that, your app will continue to receive the callbacks even if backgrounded.

The advertisement is a tricky beast as Apple implemented several optimizations to reduce the power consumption and these reduce the quality of the advertisement as soon as the app is backgrounded. Namely: the rate is reduced severely, the advertised services are not included and the local name is not included either. Once the app comes back to foreground, these restrictions are invalidated.

In the general case, this kind of backgrounded operation requires the app to be running. With iOS 7 the restoration process has been implemented that allows the OS to act on the app's behalf while it is terminated and restore the app when some transmission or other operation is imminent. This requires you to add the restoration key to the initialization options of the CBPeripheralManager/CBCentralManager. Starting your application once is still required but after that, iOS will continue to act as the BLE facade towards the centrals/peripherals.

UPDATE: I ran a loop on the Apple bluetooth-dev list as well with this question and found that Core Bluetooth managers were declared to be not able to restore after reboot. This is not described in any documentation but probably was mentioned in the WWDC videos. We should file a bug and replicate it to raise Apple's awareness.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Connected peripheral in background mode (Core Bluetooth)

From Dev

Connected peripheral in background mode (Core Bluetooth)

From Dev

Central writing characteristic to Peripheral (iOS Core Bluetooth)

From Dev

Bluetooth peripheral connected to iOS doesn't work in the background

From Dev

Bluetooth peripheral connected to iOS doesn't work in the background

From Dev

Core Bluetooth unable to discover peripheral

From Dev

Core Bluetooth deprecations for iOS 7

From Dev

Making ios7 BLE peripheral to work in background

From Dev

iOS App Bluetooth cannot connect to peripheral device

From Dev

iOS 7 Background Fetch When the App is Not Running

From Dev

Get MAC address of bluetooth low energy peripheral in iOS

From Dev

iOS: Bluetooth LE peripheral no longer updating after coming back into range

From Dev

Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

From Dev

Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

From Dev

Core bluetooth ios 8

From Dev

Sending Data To Server While App is Running in Background in iOS 7

From Dev

How large is the battery emissions while running an iOS Bluetooth Low Energy app in the background

From Dev

Transferring Data from Central to peripheral in Background mode in iOS

From Dev

Running Background Service in iOS

From Dev

iOS 7 Bluetooth - app that handles events in background even after phone restart

From Dev

iOS 7 Bluetooth - app that handles events in background even after phone restart

From Dev

My bluetooth peripheral is sometimes not recognized by my iphone in background. Proximo by Kensington works

From Dev

Android 4.3 as a Bluetooth LE Peripheral

From Dev

alert in background ( ios 7 )

From Dev

iOS 7 view background

From Dev

Bluetooth LE Device scan in background from iOS

From Dev

iOS - Cancel bluetooth connection when app in background

From Dev

Running iOS app in the background forever

From Dev

iOS keep thread running in background

Related Related

  1. 1

    Connected peripheral in background mode (Core Bluetooth)

  2. 2

    Connected peripheral in background mode (Core Bluetooth)

  3. 3

    Central writing characteristic to Peripheral (iOS Core Bluetooth)

  4. 4

    Bluetooth peripheral connected to iOS doesn't work in the background

  5. 5

    Bluetooth peripheral connected to iOS doesn't work in the background

  6. 6

    Core Bluetooth unable to discover peripheral

  7. 7

    Core Bluetooth deprecations for iOS 7

  8. 8

    Making ios7 BLE peripheral to work in background

  9. 9

    iOS App Bluetooth cannot connect to peripheral device

  10. 10

    iOS 7 Background Fetch When the App is Not Running

  11. 11

    Get MAC address of bluetooth low energy peripheral in iOS

  12. 12

    iOS: Bluetooth LE peripheral no longer updating after coming back into range

  13. 13

    Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

  14. 14

    Can iOS re-connect to Bluetooth LE peripheral by specifying )CBPeripheral *)peripheral instead of doing retrievePeripherals?

  15. 15

    Core bluetooth ios 8

  16. 16

    Sending Data To Server While App is Running in Background in iOS 7

  17. 17

    How large is the battery emissions while running an iOS Bluetooth Low Energy app in the background

  18. 18

    Transferring Data from Central to peripheral in Background mode in iOS

  19. 19

    Running Background Service in iOS

  20. 20

    iOS 7 Bluetooth - app that handles events in background even after phone restart

  21. 21

    iOS 7 Bluetooth - app that handles events in background even after phone restart

  22. 22

    My bluetooth peripheral is sometimes not recognized by my iphone in background. Proximo by Kensington works

  23. 23

    Android 4.3 as a Bluetooth LE Peripheral

  24. 24

    alert in background ( ios 7 )

  25. 25

    iOS 7 view background

  26. 26

    Bluetooth LE Device scan in background from iOS

  27. 27

    iOS - Cancel bluetooth connection when app in background

  28. 28

    Running iOS app in the background forever

  29. 29

    iOS keep thread running in background

HotTag

Archive