I'm making an iOS app to support a Bluetooth LE device. First time the app launches, we pair, but after that I want to communicate with the device whenever it is in range. Using background modes, this works fine for when the app is launched and goes into background and the screen is turned off. But, when the phone is rebooted, the app needs to be relaunched before it will be able to detect the device.
Is there any way to have the app launch in the background whenever the BLE device that it is paired to comes nearby?
In case of user forcibly kills the app by double clicking on home button and swipe out, it will not be relaunched until the user launches it again.
Coming to your case when Device is rebooted - Yes, you can configure State Preservation and Restoration to relaunch the app when user has not killed it forcibly before rebooting.
( Note: If the device requires a passcode to unlock, apps will not be relaunched until the device is unlocked for the first time after a restart )
Also, it is important to keep in mind that the app will be relaunched and restored if and only if it is pending on a specific Bluetooth event or action (like scanning, connecting, or a subscribed notification characteristic), and this event has occurred.
For more info:
Conditions Under Which Bluetooth State Restoration Will Relaunch An App
Related
UILocalNotification is not coming when i have supervise my iPad in single app mode. Same code is working fine when device is in normal mode when app is in background/killed or any other state.
But after Supervise device in single app mode with same app Notifications is not coming.
In my case app will never gone in background but may be device in sleep mode.
Scenario: Backgrounded iOS app monitoring an iBeacon region. The device's WiFi radio was powered down by iOS (30 minutes of inactivity).
When the device enters the region of the the iBeacon and the app wakes to handle the location notification, will the WiFi radio power up and connect to an available remembered WiFi network?
Sending a local notification causes the lock screen to come up. I last tested this in the past (on iOS 6) and as of that OS version, this did cause a WiFi scan to start. Assuming this has not changed in subsequent iOS releases, then yes, this would work as you say.
To be clear, though, this is nothing specific to iBeacons -- this is just about the behavior of iOS when it brings up the lock screen due to a local notification.
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.
I have a simple question when you go to home screen of iPhone and do not quit the application than the chrome Cast device stops playing the video on screen how can I keep playback alive while the application is running in background.
If you have a video app and it is running in a cast device, you would want the following behavior:
if user "explicitly" disconnects a device (through the cast menu), then receiver should look at the connected devices and see if there is any "other" connected device. If there is none, it should stop the application on the cast device. If, however, it finds another connected device, it should not stop the app.
If user doesn't explicitly disconnect but device gets disconnected since the app goes into background, or phone goes out of wifi range, or it battery dies, or ..., then receiver should not stop the app and should let it run, even if there is no other connected sender.
If you follow these two in the design of your app and your receiver, then you shouldn't have any issue when your phone goes to sleep or your app goes to background. Do you still see an issue given the above?
I'm developing a "background task enabled" app that connects to a BLE (bluetooth low energy) device. The user opens the app and connects to the BLE while the app is in the foreground. Once the app goes to the background it will keep communication open with the device (if in range) and be alert of any information received from such device. Now my question is how do I handle or even notice that data is coming from the device? It seems that right now my notifications are queued and are only shown when I manually bring the app to the foreground.
Thanks,
Andres N.