public abstract class

NotificationFactory

extends Object
java.lang.Object
   ↳ com.urbanairship.push.notifications.NotificationFactory
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This abstract class provides a pathway for customizing the display of push notifications in the Android NotificationManager.

Summary

Public Constructors
NotificationFactory(Context context)
Public Methods
abstract Notification createNotification(PushMessage message, int notificationId)
Creates a Notification for an incoming push message.
Context getContext()
abstract int getNextId(PushMessage pushMessage)
Creates a notification ID based on the message and payload.
Protected Methods
final NotificationCompat.Extender createNotificationActionsExtender(PushMessage message, int notificationId)
Creates a notification extender with actions applied.
final NotificationCompat.Style createNotificationStyle(PushMessage message)
Creates a notification style.
final Notification createPublicVersionNotification(PushMessage message, int notificationIcon)
Creates the public version notification.
final NotificationCompat.WearableExtender createWearableExtender(PushMessage message, int notificationId)
Creates a notification extender with wearable extensions.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public NotificationFactory (Context context)

Public Methods

public abstract 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 BaseIntentReceiver. When the notification is opened it will call onNotificationOpened(Context, PushMessage, int) 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 Context getContext ()

public abstract int getNextId (PushMessage pushMessage)

Creates a notification ID based on the message and payload.

This method could return a constant (to always replace the existing ID) or a payload/message specific ID (to replace in cases where there are duplicates, for example) or a random/sequential (to always add a new notification).

Parameters
pushMessage The push message.
Returns
  • An integer ID for the next notification.

Protected Methods

protected final NotificationCompat.Extender createNotificationActionsExtender (PushMessage message, int notificationId)

Creates a notification extender with actions applied.

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

protected final NotificationCompat.Style createNotificationStyle (PushMessage message)

Creates a notification style.

Parameters
message The push message.
Returns
  • The notification style or null if it failed to be created.
Throws
IOException

protected final Notification createPublicVersionNotification (PushMessage message, int notificationIcon)

Creates the public version notification.

Parameters
message The push message.
notificationIcon The notification icon.
Returns
  • The public version notification or null if it failed to be created.

protected final NotificationCompat.WearableExtender createWearableExtender (PushMessage message, int notificationId)

Creates a notification extender with wearable extensions.

Parameters
message The push message.
notificationId The notification ID.
Returns
  • The wearable notification extender.
Throws
IOException