iOS Question Bluetooth events for background execution.

George Anifantakis

Member
Licensed User
Longtime User
Is it possible to trap the Bluetooth connection event to execute a process. I mean that the pair process has already been performed and the trap event I would like to capture is the connection event when the user switch on an already paired device.

If the above is not supported, can I use the button of the device instead? The device is a Bluetooth shutter button that it has a button upon it. Assuming that pair process of the device with iphone has already been performed.
Can I create an app to stand in the background and activated according the below actions even if the phone is idle (not switched off).
1. User opens the button from the switch. The device connects with the phone.
2. After the connection with iphone the user presses the device’s button.
3. The app in the background gets the button signal (validate the Bluetooth friendly name) and perform and action like to find current location and send and sms message.

If there is another way to accomplish the above?

Also after searching I found the blow:
https://developer.apple.com/library...ormingTasksWhileYourAppIsInTheBackground.html
The bluetooth-peripheral Background Execution Mode
When this key-value pair is included in the app’sInfo.plistfile, the system wakes up your app to process read, write, and subscription events.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is worth reading this page: http://stackoverflow.com/questions/...ooth-applications-do-whilst-in-the-background

Your app can start scanning for BLE peripherals and then the scanning will continue even if your app is in the background. Based on my understanding it will not work when the phone is sleeping.

If you are creating a non-app store application then it is possible to force the process to keep running in the background.
 
Upvote 0

George Anifantakis

Member
Licensed User
Longtime User
Reading the post at the end it seems like for new versions 8 and above implementations regarding this issue have been performed.

Also the official apple thread
includes the below

Core Bluetooth Background Execution Modes
If your app needs to run in background to perform certain Bluetooth-related tasks, it must declare that it supports a Core Bluetooth background execution mode in its Information property list(Info.plist) file. When your app declares this, the system wakes it up from a suspended state to allow it to handle Bluetooth-related events. This support is important for apps that interact with Bluetooth low energy devices that deliver data at regular intervals, such as a heart rate monitor.

It clearly say that the system wakes it up from a suspended state...
 
Upvote 0
Top