I think what Michael is suggesting is using local notifications to set up a 15 minute timer. These are long-running timers delivered to the application just like push notifications. The app can be put in the background (or completely shut down). Once the timer expires you get the notification via the didReceiveLocalNotification method on the app delegate at which time you can scan for peripherals.
The only thing is that just like push notifications the user will be presented with an alert view telling them the timer has expired and they have the option of hitting 'cancel' and preventing the alarm from being delivered. However, if your UX workflow allows for this it's a good way to go.
Another method is if the app deals with sound, you can register it as an audio playback app and have it play a 1 second silent track in a loop. This allows the app to continue running actively even in the background and the watchdog timer will not kick it out. Obviously, it will affect battery life and may be rejected from the app store unless there's a legitimate reason for it to be playing audio in the background.
Best, Ramin
On Aug 9, 2012, at 9:23 AM, Justin Shorney wrote: We did some testing along these lines and a timer that runs for 15 min won't work in the background. You have to hook into the didDiscoverPeripheral at some point. Once this call is issued in the background you have aprox. 10seconds to do what you need to do before the watchdog gets you (or to register for a long running background task). That is unless another didDiscoverPeripheral gets called in which case you have another 10 seconds or so. If your iOS device is going to be in constant proximity of your Bluetooth object you could store the initial discovery time and check if 15min have passed on the subsequent discoveries.
Sent from my iPhone On Aug 9, 2012, at 8:48 AM, Michael Kroll < email@hidden> wrote: What about local notifications? Regards, Dr. Michael Kroll. --------------------
Sent from iPhone.
Hi All,
I have an app that is currently scanning for BLE devices in the background. This part is working well, but I now need to trigger an event every 15 minutes or so. If the app subscribes to bluetooth-central, can Timers be run in the background? If not does anyone have any recommendations? Thanks in advance for any information.
Nick
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|