简体   繁体   中英

How to control iOS app from BLE device for background processing without putting the application in front

I'm developing a Bluetooth Low Energry (BLE) enabled DSLR (digital camera) controller that receives GPS coordinates and allows remote focus/shutter controls.

In the ideal case, I'd not have to take my iPhone out of my pocket. The BLE device connects as soon as my camera is turned on, and this should launch the app if it's not launched already. When the camera is turned off, BLE disconnects and the app should go into sleep mode (stop updating location and sending data over BLE) (note that app might be in background at this time). When the camera is turned off again (while app is in background/iphone locked), the app should reconnect and start updating location and sending data to the BLE receiver.

It's a lot to ask and might be too good to be true, but is this possible? (iOS 7+ SDK is OK)

You can operate as a Bluetooth LE central (scanning for peripherals) in the background - Refer to the Core Bluetooth Programming Guide however, while in the background peripheral scanning and detection may not happen as quickly as when the app is in the foreground.

Your app could post a local notification when the peripheral was detected, and the user could respond to this notification to launch your app into the foreground, but you cannot force your app into the foreground without user interaction. You can send information to the camera via BLE even while your app is in the background and you can receive location information while in the background too - refer to the Core Location programming guide.

The disconnection is straight-forward. When you detect a disconnection you can shut down location services to conserve battery power.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM