Nearby Notifications

Peter-John Welcome
AndroidPub
Published in
4 min readMar 17, 2017
https://tinyurl.com/l9rfuoh

I’ve been playing around with Beacons for a while and I think within the Google Beacon Platform suite of features, Nearby Notifications are the most awesome.

What are Nearby Notifications?

Nearby Notifications are location-specific notifications that can be sent to users for any app or website without the user having any associated app installed on their device.

This on its own is super awesome. But how does it all work and how do us as developers send these notifications to our users?

We go back to the Google Beacon Platform for this.

Creating a Nearby Notification

To create a nearby notification, we go to our Google Beacon Dashboard and select our Beacon that we have provisioned. We then select the drop down labelled view details and then select Nearby Notifications. We will then be presented with the form below:

Nearby Notification form

We will need to provide a title for our notification, a language code that conforms to the ISO 639–1 standard and we also need to either provide a web URL, an intent or both. This is where the magic comes from.

At this point we will provide the form with a URL that is HTTPS, as this does not work with URLs that are not secure. Then we click the Create button to create the Nearby Notification and then click Save at the top of the form to save the notification to the beacon.

This will then start broadcasting that URL from your beacon to any android device that is set to receive Nearby notifications.

This is super awesome, but there’s more. We can use this technique to not only broadcast URLs but also Android Intents. This works especially well if you want to broadcast a deeplink. To do this, we go back to the Nearby Notification form and next to the Web URL, we click the dropdown and choose App Intent. This will provide us with a field where we can insert our intent path. This needs to conform to a specific path format:

intent://host/path#Intent;scheme=yourscheme;package=com.yourapp.ui;

Once we have created our path and have added this to our Nearby Notification form, we need to create an intent filter in our android app that will respond to this notification once it appears on the user’s device.

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<!-- both categories below are required -->
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:host="host"
android:pathPrefix="/path"
android:scheme="yourscheme"/>
</intent-filter>

Note: Nearby Notifications with app intents only work with apps that have been published to the Play Store.

This feature is useful when people already have your app installed and you would like to guide them to a specific place in the app, or if they don’t have your app installed they could be guided to the Play Store to download it.

In addition to this, we can also have a combination of both an app intent and a fallback URL:

intent://host/path#Intent;scheme=yourscheme;package=com.yourapp.ui; \
S.browser_fallback_url=http%3A%2F%2Fm.yoursite.com%2Fpath%2F%;end

To further enhance our notifications, we can also implement another feature that was recently added to Nearby Notifications called Targeting Rules.

Targeting Rules

Targeting Rules are basically ways for us as developers to specify times, dates or days when we would like our Nearby Notification to be shown. This could be used for promotional purposes or when the notification only needs to be shown at a specific time of day as shown below:

Nearby Notifications is a really powerful feature that the Google Beacon Platform provides to us.

Go try it out and let me knows what you peeps think ;)

Stay tuned for more posts soon.

Get in touch!

Thanks to Ashton Welcome and Joshua Leibstein for reviewing this post.

--

--

Peter-John Welcome
AndroidPub

Freelance Senior Mobile Engineer, Google Developer Expert for Firebase, Photographer