public class

CustomLayoutNotificationFactory

extends NotificationFactory
java.lang.Object
   ↳ com.urbanairship.push.notifications.NotificationFactory
     ↳ com.urbanairship.push.notifications.CustomLayoutNotificationFactory

Class Overview

A notification factory that allows the use of layout XML. The default binding will bind the following: - small icon to android.R.id.icon - title to android.R.id.title - summary/subtitle to android.R.id.summary - alert/message to android.R.id.message Custom binding can be applied by overriding onBindContentView(RemoteViews, PushMessage, int). To customize the builder, override extendBuilder(NotificationCompat.Builder, PushMessage, int).

Summary

[Expand]
Inherited Constants
From class com.urbanairship.push.notifications.NotificationFactory
Public Constructors
CustomLayoutNotificationFactory(Context context, int layoutId)
Default constructor.
Public Methods
final Notification createNotification(PushMessage message, int notificationId)
Creates a Notification for an incoming push message.
NotificationCompat.Builder extendBuilder(NotificationCompat.Builder builder, PushMessage message, int notificationId)
Called to apply any final overrides to the builder before the notification is built.
void onBindContentView(RemoteViews contentView, PushMessage pushMessage, int notificationId)
Called to bind the content view to the push message.
[Expand]
Inherited Methods
From class com.urbanairship.push.notifications.NotificationFactory
From class java.lang.Object

Public Constructors

public CustomLayoutNotificationFactory (Context context, int layoutId)

Default constructor.

Parameters
context The application context.
layoutId The custom content view.

Public Methods

public final Notification createNotification (PushMessage message, int notificationId)

Creates a Notification for an incoming push message.

In order to handle notification opens, the application should register a broadcast receiver that extends AirshipReceiver. When the notification is opened it will call onNotificationOpened(Context, AirshipReceiver.NotificationInfo) giving the application a chance to handle the notification open. If the broadcast receiver is not registered, or false is returned, an open will be handled by either starting the launcher activity or by sending the notification's content intent if it is present.

Parameters
message The push message.
notificationId The notification ID.
Returns
  • The notification to display, or null if no notification is desired.

public NotificationCompat.Builder extendBuilder (NotificationCompat.Builder builder, PushMessage message, int notificationId)

Called to apply any final overrides to the builder before the notification is built.

Parameters
builder The notification builder.
message The push message.
notificationId The notification ID.
Returns
  • The notification builder.

public void onBindContentView (RemoteViews contentView, PushMessage pushMessage, int notificationId)

Called to bind the content view to the push message.

Parameters
contentView The custom content view.
pushMessage The push message.
notificationId The notification ID.