Notifications

The Notifications module contains all the functionality for receiving, tracking, displaying and handling notifications. It also contains the NotificationCenter along with the deep link support for presenting it.


Assembler

Rover.initialize(
    // ...,
    NotificationsAssembler(
        applicationContext = this,
        notificationCenterIntent = Intent(
            context,
            MyNotificationCenterActivity::class.java
        ),
        smallIconResId = R.mipmap.my_small_icon,
        requestPushToken = { tokenFutureCallback ->
            FirebaseInstanceId.getInstance().instanceId.addOnCompleteListener { task ->
                tokenFutureCallback(task.result?.token)
            }
        }
    )
)

smallIconResId: Int

A small icon is necessary for Android push notifications. Pass a drawable res id here. Android will display it in the Android status bar when a notification from your app is waiting, as a monochromatic silhouette.

Android design guidelines suggest that you use a multi-level drawable for your general application icon, such that if you want to use that same icon for your smallIconResId you can specify one of its levels (using smallIconDrawableLevel) that is most appropriate as a single-colour silhouette that can be used as a notification status bar small icon.s

smallIconDrawableLevel: Int

(Optional) The drawable level of [smallIconResId] that should be used for the icon silhouette used in the notification drawer.

defaultChannelId: String

(Optional) Since Android O, all notifications need to have a “channel” selected, the list of which is defined by the app the developer. The channels are meant to discriminate between different categories of push notification (eg. “account updates”, “marketing messages”, etc.) to allow the user to configure which channels of message they want to see from your app right from the Android notifications area.

You should consider registering a set of channels when When configuring your campaigns you should consider setting the channel ID. If you do not, then the push notifications arriving in your app through that campaign will instead be published to the Android notification area with the default channel ID “Rover”.

If you give an unregistered channel, or leave it set as the default, “Rover”, Rover will attempt to register and configure it with the Android OS for you. However, the channel description and other metadata will be descriptive.

Details on how to setup and use your Android notification channels can be found in the Android documentation's Create and Manage Notification Channels guide.

notificationCenterIntent: Intent

(Optional) Provide an Intent for opening your Notification Center. While you can refrain from providing one, in that case the Rover SDK will use a very simple built-in version of the Notification Center which is probably not appropriate for the final version of your product.

requestPushToken: (tokenFutureCallback: (token: String?) -> Unit) -> Unit

In addition to your FirebaseMessagingService receiving push token updates, Rover also will actively request the push token on app startup to ensure that it is up to date. However, because Rover itself does not link to the Firebase Messaging library, you have to bridge the gap between Rover and the Firebase library by providing a small bit of boilerplate. This does involve a bit of callback closure nesting.

The Firebase API for requesting the push token is asynchronous, so Rover will ask you to request the push token from Firebase, which is then delivered to a closure you pass to it that serves as the “on complete” listener. Then you should deliver the token back to Rover, using a Callable passed to your closure.

Pass a closure like the following:

requestPushToken = { tokenFutureCallback ->
    FirebaseInstanceId.getInstance().instanceId.addOnCompleteListener { task ->
        tokenFutureCallback(task.result?.token)
    }
}
System Frameworks
  • AppCompat
  • Kotlin Stdlib
  • Support Design
  • Support RecyclerView
  • Support v4
  • Support Vector Drawable
Dependencies