I want to achieve a certain behavior in my application - regardless of the app's state. When a user connects to a bluetooth device from his phone, I want to get a notification in my app and do something. I tried to achieve this using AVAudioSession.routeChangeNotification
but it seems to work only when the app is in the foreground. I read that the events newDeviceAvailable
and oldDeviceUnavailable
will be triggered in the background only if my app plays music. However my app doesn't - I just want to know that there're a connection change. Are there any manipulations that can be done, to listen to those events even if the app is in the foreground/killed?
Is it possible to have a notification in my app when user connects to bluetooth while in background?
Asked
Active
Viewed 337 times
0

Keselme
- 3,779
- 7
- 36
- 68
-
I'm not sure Apple wants you doing this :D – Josh May 19 '21 at 09:25
-
Does this answer your question? [iOS Detect Bluetooth connection/disconnection](https://stackoverflow.com/questions/48284737/ios-detect-bluetooth-connection-disconnection) – Abhishek Mitra May 19 '21 at 11:47