Question

I'm working on iOS development for a bluetooth peripheral. We want the (already paired) device to connect when a button is pressed on it, and this will cause the app to execute some code. Is it possible for the app to detect that the device is connected, even while in the background?

Also, is it possible for the app to bring itself into the foreground when this is detected? Would I need to be a member of the MFi program to do either of these things?

Was it helpful?

Solution

You will be able to detect that the device is connected in the background using Bluetooth 2.0, however you must include the App communicates with an accessory string under Required Background Modes in the app's plist.

So yes, the first part of your question is doable. However when you say: "We want the (already paired) device to connect when a button is pressed on it", it is important to note that this functionality must be built into the device's firmware. The app can always be searching for it, but the device will not be able to communicate with the phone until it connects. Therefore, the button must wake up the device and signal that it now wants to connect.

For the third part of your question, you will not be able to bring the app into the foreground without the user opening the app.

Btw, CoreBluetooth is the Bluetooth Low Energy framework for iOS. It is completely different from Bluetooth 2.0.

OTHER TIPS

as ttarules told you iphone can't connect automaticly to a paired device.

I don't know what kind of bluetooth receiver have you in your device but generally you can set up a method of "AUTOCALL" that automatically call a paired device (in this case an iPhone).

When you (your iPhone) come around the device it automatically establish a connection!

If you set all the parameters correctly in the bluetooth module you can make sure that the iPhone shows a message like this: "YourDevice would like access to YourApplication" when the connection is established.

this way helps the user to use your application and you can run the code you mentioned above when the app start.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top