Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to write a tracking application, which reacts/record when users get in a car and phone automatically pair with Bluetooth hands free. I need also Id of the hands free device.

On Android it is easy, using Broadcast Receiver your app listen to broadcasts that device had been paired with phone. It is working even after phone had been restarted and App did not run after restart.

Is it possible on iOS(7+) ?

like image 206
Michal Dobrodenka Avatar asked Sep 30 '22 20:09

Michal Dobrodenka


1 Answers

You can do it by reading the "Performing Long-Term Actions in the Background" part of this docs

Essentially, using state restoration, the system takes note of what your app was doing when it was killed.
If the app is searching for a bluetooth device and is killed by the system, the system will take care of continuing this research and wake up the app again when the bt device has ben found.
Note that this will work only if the app is killed by the system, not by the user (using the multitask bar). This behavior has changed since iOS 7.

like image 141
LombaX Avatar answered Oct 05 '22 06:10

LombaX