Receive signal from beacon while app is in the background

I have a iOS app that interact with a beacon.
Also have a function to detect the signal from a beacon and if the signal is out of range I want to store something in the database (in this case core data)

    func updateDistance(distance: CLProximity) {
    UIView.animateWithDuration(1.0) { [unowned self] in
        switch distance {
        case .Unknown:
            self.view.backgroundColor = UIColor.grayColor()
            self.distanceReading.text = "No Beacon Signal Detected"


So the app works fine as long as the app is running in foreground.
My understanding is I can also have the app in the background when user not actively using the app and still get signal from beacon.
If so, how can I accomplish this task?
I added the following to info.plist and still didn’t work.
Also is it possible to update the database as well?enter image description here

  • How can I pass a gesture recognizer from one view to another
  • Best way to set a retained property to a newly created object
  • Animations not working in ios playground
  • Native Facebook Login stopped working after SDK update to 3.14
  • Using CGContext to draw line
  • how to make uipageviewcontroller go in circles
  • Solutions Collect From Internet About “Receive signal from beacon while app is in the background”

    You can only range beacons (which is what gives you access to the distance approximations) when the app is running. As soon you leave the app (press the home button, navigate to another app, etc.), iOS will suspend the app, and ranging will stop working. Continuous usage of Bluetooth radio in the background would drain the smartphone’s battery quickly.

    You can, however, have your app subscribe to be woken up into the background when the smartphone enters and exits range of a beacon (or a group of beacons). This is called region monitoring, and it’s the same mechanism that geofencing uses.

    Now, “enter” and “exit” events in and on themselves won’t give you access to distance approximations. However, since iOS will wake your app into the background for a few seconds to handle these events, ranging will actually resume for the duration (assuming you haven’t stopped it before the app got suspended), before iOS puts the app back to sleep again.

    You can even extend the “few seconds” into up to a few minutes with a background execution task.

    All of the above doesn’t require the use of background modes—only the “always” authorization to use Location Services.

    You can’t ordinarily keep the app running in the background indefinitely with beacons. Background support is heavily regulated by Apple, and is only allowed, e.g., for navigation apps, or music apps. People do on occasion try using the “location” background mode to keep the app alive in the background (and thus capable of ranging beacons), and some even reported being able to get it past the review process, but that seems to be more of an exception than a rule.

    Should you decide to give it a try anyway, you need to:

    • enable the “location” background mode,
    • set allowsBackgroundLocationUpdates to true on your CLLocationManager instance,
    • start regular location updates: startUpdatingLocation.

    This should keep the app running in the background even if you leave it.