Select Page

Urban Airship Logo

Urban Airship is a popular messaging and notification service. In this post we’ll look at how to set up Urban Airship push notifications. The eventual goal is to use these notifications to trigger replications in Couchbase Mobile.

What you’ll need

  • An Urban Airship account
  • A Firebase account (requires a Google Login account)
  • Android Studio (or Xcode)

You can use Urban Airship (UA) for free. (See the UA web site for current pricing details.) You do have to register an account.

Setting up

Bring up an existing Android or iOS project in your IDE (or create a new one). Here I’ll illustrate using Android.

Sign in to your UA account. Navigate to the New App page. Fill in your app name. Select the platforms you want to use. (We’ll pick Android and iOS for this example.) Hitting “Save” will take you to the quickstart quide.

Urban AIrship New Application Dialog

UA quickstart

Here you’re offered a tab for each platform selected. As mentioned, we’ll focus on building for Android this time.

Follow the Urban Airship quickstart steps. I have a few tips for issues I encountered.

Steps 1 & 2

The UA guide refers to the project’s build.gradle script, but then shows modifying the module build.gradle script. I added the UA repository to my project’s gradle script, and the UA dependency to the module gradle script. That worked fine.

Look for the applicationID in the module gradle script.

Step 5

To create your own Application class, right click in the app area of the Project navigation pane and pick New > Java Class. In the popup, set the class name. Then for the Superclass enter android.app.Application.

Android Studio New Java Class Dialog

Don’t forget to update your manifest file. You can use the fully qualified name of your class, or the short form that UA shows. The fully qualified form looks like this:

Step 6

UA uses Firebase Cloud Messaging (FCM). Step six has a link to further documentation by UA. This new page has detailed instructions on creating an API key for your app.

The instructions on that page under the heading ‘Configure FCM/GCM Service with Urban Airship’ are a little out of date. You’ll find the area to enter your Api Key and Package at the end of the quickstart guide now, instead of where the docs say to look.

In one place, the UA docs refer to the “Google API Project Number”. This is what FCM calls your Sender ID.

Testing

The quickstart ends with a testing area, without much instruction. If you look back at the code included in your Application subclass, you’ll see it’s enabling user notifications. To test, build your app and install it on an emulator or device. (I tried both and they worked fine.)

Urban Airship Test Message Interface

Enter something into the text field and click “Send Test”. You should see an icon show up in the Android notification area. Oddly, this doesn’t include the text entered into the test area.

For troubleshooting UA directs you to an obscure “Error Console” link in the lower right corner of the documentation page. The link just brought me back to the quickstart guide, unfortunately.

Wrapping up

In the end setting up Urban Airship was pretty quick. The quickstart shows how to send an alert notification. To trigger data sync in a Couchbase Lite client, we’ll want to send a silent alert instead. That’ll be the subject of a future post.

This post originally appeared on https://blog.couchbase.com/.

Share This