Introducing Background Nearby with iBeacons
· by Dasmer Singh, iOS Engineer
Beacons are game-changing. Ever since Apple extended its developer API to support beacons in iOS 7, articles and blog posts have inundated the web to extol their use-cases in retail. Apple has pioneered this initiative by placing beacons throughout its stores, to notify and educate customers about the products they are standing next to as they walk around.
At Venmo, we were eager to learn more about how beacons work and excited to explore their potential. We wrote and open-sourced VENPromotionsManager, an iOS library that schedules in-app promotions that trigger when a user enters specified regions created by beacons. To experiment, we loaded our offices with Estimote beacons which triggered fun little messages on internal builds of Venmo.
When Apple introduced its iOS 7.1 update, we noticed that they had vastly improved beacon scanning by moving this responsibility from the app-level to the core OS-level. To our surprise, our devices were notifying us of entering a beacon’s region even if Venmo was not running in the background. In addition, our iPhones were detecting these beacons much faster than before (in fewer than 2 seconds on average).
In February, we introduced Venmo Nearby, which utilizes Apple’s MultiPeer Connectivity (MPC) framework to discover nearby users over Bluetooth Low Energy (BLE) and WiFi Bonjour networks. We’ve received more positive feedback and press about Nearby than any other feature we had ever released.
Our users loved Nearby, but one thing prevented the feature from being as useful as we would have liked it to be: both users needed to have the Venmo app open in order to discover one another. This limitation is inherent in Apple’s MPC framework, which only allows devices to broadcast and listen for unique peer identifiers when the app is foregrounded. However, with Apple’s recent enhancements in iOS 7.1, we discovered that we could finally detect nearby Venmo users even when the Venmo app has been terminated and a user's phone is in standby.
How did we do this?
To make this work, if a user opts-in to Nearby, their device not only advertises a unique peer identifier over Apple’s MPC network, but also broadcasts a beacon region with a UUID unique to Venmo whenever the app is open and active. Devices that have Background Nearby enabled are always scanning for this Venmo beacon region, even if they are locked and their screens are off (this scan uses extremely low battery power because it utilizes Bluetooth LE). Whenever a device enters a beacon region, it briefly launches the Venmo app into the foreground in order to broadcast its peer identifier over the MPC framework, thus establishing a Nearby connection. In other words, whenever our users open Venmo to pay or charge the people they are around, they can instantly emit a beacon signal that momentarily wakes up their friends’ devices to connect and populate the user's Nearby drawer. This makes Nearby more powerful and useful than ever before.
We released Background Nearby in our latest update to the Apple App Store and are extremely excited for our users to try it out! At Venmo, we believe that in order to create an extraordinary experience for our users, we need to provide a service that enables them to spend more time cherishing the moments they value with the ones they are with and less time figuring out how to settle the bill. With solutions like Background Nearby, we hope to keep innovating and do just that.