2

I am working on one of the iOS app which is related with Core Bluetooth framework of Apple.

My App uses the BLE mechanism to detect Peripheral iOS devices. When app is in foreground, external device's bluetooth is in range of iPhone bluetooth than app is notified and some kind of defined animation which is played in app. I enabled the Background service for app using info plist like

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>

When app is not in Background or suspended state (it should be killed state) than also we need notification from external device to our iOS app. Is this possible? If yes, than how can we achieve this mechanism.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Anil Gupta
  • 1,155
  • 1
  • 19
  • 26
  • 1
    Check this question and its answer: https://stackoverflow.com/questions/43578813/corebluetooth-and-ios-states. – Max Pevsner Jun 08 '17 at 14:42
  • Your answer doesn't demonstrate how it will work in killed state. We need to work on killed state and you said it is not possible. – Anil Gupta Jun 08 '17 at 14:56
  • 1
    _it's not possible_ - that's exactly the demonstration on how the app works in a killed state. – Max Pevsner Jun 08 '17 at 14:57
  • The only thing that helps you is Apple's "State Preservation and Reservation" for Bluetooth (https://www.google.se/search?q=state+preservation+and+restoration+bluetooth) – Emil Jun 08 '17 at 18:19
  • 1
    Yes, state preservation will relaunch your app if a relevant Bluetooth event occurs; this is a peripheral with a pending connection coming into range or a peripheral that matches a service scan comes into range – Paulw11 Jun 08 '17 at 21:20
  • is there any some snip of code that explain "state preservation will relaunch your app if a relevant Bluetooth event occurs" @Paulw11 – Anil Gupta Jun 09 '17 at 10:11
  • It is described in the CoreBluetooth programming guide and you can have a look at some sample code here: https://github.com/paulw11/BTBackground – Paulw11 Jun 09 '17 at 10:33

0 Answers0