Is it possible to have an iphone (iphone 1) send out BLE signals in the background with information such as an id number and time sent? This signal will be read by another iphone (iphone 2) running the BLE app in the foreground. iphone 2 does not need to communicate with iphone 1. It just needs to recieve the signal which i know it can, but i'm just not sure if iphone 1 will be able to send out this signal in the background.
If you're using iBeacon - no, it can't.
If you use the underlying BTLE support via CBPeripheralManager - yes, it can.
To have iPhone 1 act as a peripheral (sending data) in the background, make sure you add (in your Info.plist file), "Required background modes" -> "App shares data using CoreBluetooth".
This project lets you easily set up an iPhone to share an array of strings while in background mode with another iPhone in foreground mode: SimpleShare
Related
I am working on a medical related app where a medical device interfaces via bluetooth with an iphone. However I cannot figure out how to allow the app to run indefinately in the background. Right now it only communicates when the app is open. I have been reading a lot of questions related to this and I haven't managed to find an answer which fits. I'm sorry if this is a duplicate. Can someone point me in the direction of how to implement this.
ETA - I just got confirmation that this is supposed to be able to go on the App Store.
Did you come across this question: Background time issue for Bluetooth LE app for Iphone 4s
It seems that adding the background mode bluetooth-central (see documentation) can enable your app to run in the background while handling bluetooth events. As noted in the question above though, you could always set background mode to audio and play a blank looping audio track to keep your app alive and responding if you don't need to be on the App Store.
Is there any way to handle network events on-the-fly in iOS 4.2.1 when app in background?
To be more specific, here are two examples:
Receiving VoIP call while another app in foreground
Receiving XMPP message while another app in foreground
Use of setKeepAliveTimeout:handler: seems not possible, since minimum delay is 600 seconds (10 minutes).
Well you can keep a socket open when you add the Required background modes and add voip to you info.plist.
This will allow you to catch any incoming calls, the just notify the user with a UILocalNotification.
You can't really do it for IM system, since they do not fall in the Voip category.
I'm thinking the answer to this is no, but does anyone know if a Bluetooth connection can be maintained in the background with iOS? I'm thinking I might be able to keep it around with the finite-task background API, but I haven't found anything indicating whether that's true or not. Another option would be to use GPS notifications and just reconnect every time the app gets a location changed notification.
You a right. It's a NO.
But if you use location change notification to wake up your app, you may have a short period of time to use Bluetooth.
I think that the Bluetooth connection should be maintained, but if your bluetooth application is not the foreground application it will not receive any data / commands, when it becomes foreground it will.
It is possible, I use this trick to allow an App to use foreground APIs for iBeacons to allow the app to range even when the App is in the background.
To range for iBeacons it uses a high power API and as so this is restricted to only run when the App is in the foreground and stops all delegates being called once the App enters the background.
By playing a silent audio file and adding the AirPlay capability to your plist it allows your app to run in the background just as it would if it was in the foreground.
I'm not sure if it will work for your case but as iBeacons do use the Core Bluetooth and Core Location frameworks it might just do what you are asking.
http://yifan.lu/2013/12/17/unlimited-backgrounding-on-ios/
Note although this trick has not been patched by Apple in iOS8 beta 5 it is possible they will in an update.
If you're using iBeacons, there are built-in APIs for handling when you enter/exit a beacon region, and you typically get ~5 seconds to range for beacons at that point before the app is put to sleep. Theoretically, you could start a background task w/ expiration handler that might allow you to range for ~30 seconds while backgrounded, but I have not verified this is the case. I do know that the background task can be started when normal CLRegions are entered/exited while in the background, and there is functionally no difference between CLRegions and CLBeaconRegions in terms of region monitoring, so if I had to guess I would say this is more-than-likely possible.
Is it possible for an iphone app to continually send gps device location updates to a remote server, so the device could be "pin-pointed"?
I understand i can get the gps cords and get the app to continue to get them in the background, but im unsure about being able to send the cords to a webservice when in the background mode or if apple would even allow me.
-trav.
According to the apple documentation, I think this should be possible.
But you will not be able to use real GPS device. When running in the background you will only receive major location changes. Which are detect when the user travels into a new GSM cell.
Read more on background execution:
https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW4
I want to use accelerometer of iPhone to get the log file of accelerometer value (maybe for 24 hours). Is it possible to let accelerometer runs in background while other applications are running?
You can do it now, if your app is allowed to run in the background for other reasons. See the Core Motion API's startAccelerometerUpdatesToQueue:withHandler: method here.
Nope, it is not. You basically can't run anything but a music app in the background.
You can run the accelerometer while the phone is suspended though.
See this blog for how to do it: http://marcopeluso.com/2009/08/23/how-to-prevent-iphone-from-deep-sleeping/
I use this technique in my GPS recording app.
No, it is presently not possible, at least if you want to distribute your application through the App Store.