I've been searching around to find a straight answer to a problem I'm facing and the information is a little scattered. I'm not sure whether it's possible or not based on the answers.
Basically I'm using iBeacons
as a component to my app. The scenario is this, you have a high street with numerous shops. Each shop has 1 beacon in their window facing to the street. A generic shopping app is on the user's phone.
When a user walks up the high street I want a user to receive a notification when passing a shop. This notification would say something like "Check out MyShops
latest offers and discounts" with a prompt to open the app. This is all as the app is in the background.
All the beacons have a consistent UDID which tie to my app. And each shop would have it's own major identifier.
I want the notification to be specific to a shop (with a specific beacon major and minor) but I cannot find a way of determining which beacon was entered while in the background.
Also some shops may be close and have broadcast overlap, will the background process for entering a region trigger for each beacon you get in range of if they have the same UDID?
You can do what you want with a common app that launches the other store-specific apps once it is brought to the foreground by a user tapping the local notification.
A few points:
You must combine CoreLocation
monitoring and ranging APIs to do this. Monitoring will wake up the app into the background on beacon detection (but only for 10 secs) and ranging will give you updates every second with an NSArray
containing all visible beacons with the full beacon identifiers and a distance estimate for each.
In the ranging callback, you can compare the estimated distance to all visible beacons to determine which is closest (CLBeacon.accuracy
). The closest one is what should send the local notification for the shop.
Do not confuse the beacon ProximityUUID
with the iOS device's unique UDID. The two have nothing to do with one another.