8

after some research of iBeacon I came up with the following questions that I couldn't find extended help:

  1. How does iBeacon wake up our app? Does it wake up our app by putting our app into background mode if the app was suspended?

  2. What background mode did iBeacon put our app into? What can we do in this background mode?

  3. How long can this background mode last before it is suspended again? When it is about to be suspended, what function was invoked?

  4. How can we extend this background time if we need to?

  5. As we all know iBeacon only wakes up our app when region changes (enter/exit), but how do we relaunch user's app if user is still in the same region?

Thank you in advance.

0

1 Answer 1

18

Some answers:

  1. An iBeacon can wake up your app into the background using monitoring APIs. It can do this even if your app has not been launched since device reboot, or even if the app has been killed from the task switcher (although the latter requires iOS 7.1+) This works by your app calling the startRangingBeaconsInRegion: method on CLLocationManager, and also implementing the CLLocationManagerDelegate protocol's locationManager:didDetermineState:forRegion:, locationManager:didEnterRegion: and/or locationManager:didExitRegion: methods.

  2. Even if your app is not running, your app will get launched into the background and the above methods called when a beacon matching the passed region definition is detected. You can execute any code you want in this time that doesn't require a user interface. Typically, this includes updating application state, calling a web service, or sending a local notification to encourage the user to bring the app to the foreground. (And no, you cannot programmatically bring your app to the foreground.)

  3. The app only gets to run for about five to ten seconds in the background before being suspended again. (If your app were already in the foreground, it would get to continue running indefinitely.) If it is suspended after this brief time your class implementing the UIApplicationDelegate protocol applicationWillResignActive: method gets called.

  4. You can request additional background time by calling the beginBackgroundTaskWithExpirationHandler: method of the UIApplication class. But getting this extra time is not guaranteed, and you cannot continue to do this indefinitely.

  5. Once your app enters a region and you get a background notification, you cannot get a second notification to wake up your app for the same region until you exit it. You can game this a bit by defining multiple regions and having multiple beacons that might trigger more entries and exits. But these are all workarounds. In general you cannot relaunch the app with this technique if there is no additional entry/exit event.

4
  • Thank you david, I saw your blog post and it is very informative! I am trying to run multipeer connectivity when ibeacon wakes up my app, but from other stackoverflow posts people said multipeer connectivity cannot work in background. Do you have any insights on this?
    – Alex Su
    Jul 6, 2014 at 1:21
  • 2
    My understandung is that it is limited to apps in the foreground, yes. You can do much more with Bluetooth connectivity in the background on Android devices. Apple sets strict restrictions on v background activities to save battery life. This is good for keeping your phone charged, but has unfortunate consequences for app functionality. Jul 6, 2014 at 4:47
  • Hello @davidgyoung, after carefully reading your blog about ibeacon background reaction time I figured you used an iPhone 4s as a testing platform. I would like to confirm that I observed the same behavior on my iPhone 4s as well, the background reacting time is just plain nonsense. However, with iPhone 5s the background reaction time is nearly instant. I am not sure if you happened to have a iphone 5s that you can test with. I am using same code on both 4s and 5s.
    – Alex Su
    Jul 12, 2014 at 23:49
  • 2
    For those delegate methods you have to call startMonitoringBeaconsInRegion: not startRangingBeaconsInRegion: Aug 3, 2016 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.