Android Notification Improvements

A few weeks ago, we released the 5.1.0 version of the Urban Airship Android SDK.

Several new features were added to improve displaying more engaging notifications:

  • Full support for the new Android Lollipop notification enhancements, including the ability to send heads-up notifications
  • Notification styles support for the big text, big picture, and inbox styles
  • Extended Android Wear support

All these features are available out of the box, and are driven through the Urban Airship Push API.

Android Lollipop feature support

With the new Android 5.0/Lollipop release last month, Google has made huge strides in making Android’s notifications more visible, configurable and accessible. It is now possible to display notifications on the lock screen and set notification priority.

Notification Priority

Notification priority is used for determining the notification sorting order and acts as a display hint. High-priority notifications are displayed as a heads-up notification, while low-priority notifications do not notify the user when added to the list of her current notifications.

Heads-up notification with customizable action buttons

Priority can be sent with the notification by defining it in the Push API:

{  
            "android": {
                      "priority": 0
            }  
}

The priority is a number between -2 (minimum priority) and 2 (maximum priority). Any value below 0 is considered low priority, and any value greater than 0 is high priority. Using the correct priority for the notification is important. Android design guidelines provide helpful information to correctly set the proper priority.

Lock screen privacy

Now that notifications can appear on a device’s lock screen, it can sometimes be inappropriate to display sensitive information in a notification. Luckily, Lollipop provides APIs to specify when to show a notification on the lock screen and, even better, a way to show a redacted “public” version of a notification.

Visibility

The notification’s visibility is a value between -1  and 1. To define it, set the visibility in the Push API:

{
               "android": {  
                       "visibility": 0
               }
}

The default value of 1 (public) indicates that the notification should be fully displayed on the lock screen.

Visibility 0 (private) will show an automatic redacted version of the notification.

 

A value of -1 (secret) will hide the notification completely from the lock screen.

Public Notification

Android will automatically provide a redacted version of the private notification for the lock screen as seen above, but they also provide a way to specify your own version. It’s referred to as a “public” notification and can be set directly from the Push API:

{  

         "android": {  
                    "visibility": 0
                    "public_notification" : {
                             "title" : "Urban Airship",
                             "alert" : "Secret notification",
                             “summary”: “Unlock to see the full notification
                     }
          }  
}

Notification styles

Android began to support enhanced notification styles that can include images, lists or longer text in Jelly Bean (4.1). These styles provide an extended, richer layout when the notification is expanded, and still show the basic notification when it is collapsed.  Prior to our Android SDK 5.1.0, the only way to use these notification styles was to write a custom notification factory and define a custom push extras scheme. Now it can be defined directly through the Urban Airship Push API.

Big Picture

Add a big picture below the notification’s title.

{

              "android": {
                        "style": {
                                   "type": "big_picture",
                                   "big_picture": “http://placekitten.com/g/200/300”,
                                   "title": "Kitty cat",
                                   "summary": "so rich"
                         }
              }
}

Big Text

Display the alert in a multi line view.
{
              "android" : {
                           "style" : {
                                      "type": "big_text",
                                      "big_text": “Place any large alert message here and it will be
                          fully visible on an android device!”,
                                      "title": "Big Text",
                                      "summary" : "so rich"
                           }
              }

}

Inbox Style

Display up to five lines of text when the notification is expanded.

{

            "android": {
                       "style": {
                                   "type": "inbox",
                                   “lines”: [ “first line”, “second line”, “third line”],
                                   "title": "Inbox style!",
                                   "summary": "so many lines!"
                        }
            }
}

Android Wear

Android Wear is Google's approach to wearables. Notifications automatically appear on a connected Wear device, so by proxy Urban Airship already supports Wear. We have extended Android Wear support to include adding additional pages of information, customizing the notification’s background and limiting display of notifications on a Wear device.

Sending the background image

The background image behind the notification info cards can be customized to any

hosted or local image:

{  
                "android": {  
                          "wearable": {
                                       “background_image”: “http://placekitten.com/g/300/300”
                          }
                }  
}

Adding additional pages

One of the primary goals of Android Wear is to prevent the user from needing to pull their phone out of their pocket as often. This means including extra information when possible. When displaying a notification, it's possible to add extra pages of information that will display after the base notification as separate pages:

{  
                "android": {  
                        "wearable": {
                                     “extra_pages”: [
                                                {
                                                             “title”: “More?”,
                                                             “alert”: “So much information can be added here.”
                                                },
                                                {
                                                             “title”: “Even more?”,
                                                             “alert”: “How can this be”
                                                }

                                   ]
                         }
                 }
}

Local only

Just like the lock screen, it can sometimes be undesirable for the user to have a private notification appear on the Wear device. To prevent the notification from displaying, set “local_only” to true in the Push API:

{  
         "android": {
                    "local_only": true
         }  

}

These new Android notification types, along with granular controls, enable you to offer a richer, more engaging experience to users. We'd be happy to talk to you about your use case and recommend the ideal solutions to maximize value for your users.