oskob
oskob

Reputation: 1376

iBeacons: Detect proximity change in background

I'm trying to understand how you are supposed to detect proximity changes in the background. The only window I get to range is when I enter a region, but this might be pretty far away.

I would like to present something when the user enters "near" or "immidiate", but if you get "didEnterRegion" at far, than stand around, then approach the beacon, you don't get any more ranging time, because you are still in the same region.

Is there a way to either extend the "ranging" time to let the user get near the beacon, or can you make "enterRegion" happen at a different proximity than "far"?

Upvotes: 0

Views: 932

Answers (4)

brontus
brontus

Reputation: 91

In the best practices section in Apple's Getting Started with iBeacon guide it mentions that ranging API should not be used in the background.

• Ranging API are not expected to be used in the background. For best results, ranging should be used when your app is frontmost and the user is interacting with your app.

Could be a shortcut to app rejection, so take caution.

Given this, you shouldn't really be expected to determine proximity when in the background. I'm also employing the low signal technique, but it becomes a little trickier to differentiate between beacons when you only use one monitored region for multiple beacons...

Upvotes: 1

James Nick Sears
James Nick Sears

Reputation: 929

This walkthrough shows how to do what you're asking. I'm in the process of adapting and testing it for iOS 8, but the resulting app works well on iOS 7, pushing local notifications whenever the proximity changes.

Upvotes: 1

davidgyoung
davidgyoung

Reputation: 64916

Background ranging time is limited to a few seconds as Charles says in his answer.

If you need to delay action until you are in the immediate region, then you must use iBeacons that allow you to reduce the transmit power so the transmission radius is smaller. The RadBeacon product from RadiusNetworks has this configurability for this exact purpose.

If you configure a RadBeacon for minimum transmit power, your phone will not detect it until it is a few feet away, sending you the entry event and starting your limited ranging window at that time.

Full disclosure: I am Chief Engineer for Radius Networks.

Upvotes: 2

CharlesA
CharlesA

Reputation: 4350

What's possible with iBeacons in background is pretty limited.

What you can do is monitor regions in the background (which gives you the didEnter / didExitRegion events).

You can also switch on ranging for the beacon and, for the 10 or so seconds after you get a beacon enter / exit event from region monitoring you will also get ranging info (i.e. the immediate / near / far data).

Perhaps you could trigger a local notification at that point to try to get the user to bring your app into foreground - then you'd be able to get the ranging data. If not then, based on my tests, you're only going to get the 10 seconds of ranging data.

To your question about adjusting the ranging time or adjusting the enterRegion proximity - no, these aren't possible in the current version of iOS.

Upvotes: 0

Related Questions