public class

PushManager

extends AirshipComponent
java.lang.Object
   ↳ com.urbanairship.AirshipComponent
     ↳ com.urbanairship.push.PushManager

Class Overview

This class is the primary interface for customizing the display and behavior of incoming push notifications.

Summary

Constants
String EXTRA_NOTIFICATION_ID The notification ID extra contains the ID of the notification placed in the NotificationManager by the library.
String EXTRA_NOTIFICATION_TAG The notification tag extra contains the tag of the notification placed in the NotificationManager by the library.
[Expand]
Inherited Fields
From class com.urbanairship.AirshipComponent
Public Methods
void addNotificationActionButtonGroup(String id, NotificationActionButtonGroup group)
Register a notification action group under the given name.
void addNotificationActionButtonGroups(Context context, int resId)
Adds notification action button groups from an xml file.
void addNotificationStatusListener(PushNotificationStatusListener listener)
Adds an Airship push notification status listener.
void addPushListener(PushListener listener)
Adds a push listener.
void addPushTokenListener(PushTokenListener listener)
Adds a push token listener.
boolean areNotificationsOptedIn()
Checks if notifications are enabled for the app and in the push manager.
Predicate<PushMessage> getForegroundNotificationDisplayPredicate()
Gets the foreground notification display predicate.
String getLastReceivedMetadata()
Returns the send metadata of the last received push.
NotificationActionButtonGroup getNotificationActionGroup(String id)
Returns the notification action group that is registered under the given name.
NotificationChannelRegistry getNotificationChannelRegistry()
Returns the shared notification channel registry.
NotificationListener getNotificationListener()
Gets the notification listener.
NotificationProvider getNotificationProvider()
Gets the notification provider.
PushNotificationStatus getPushNotificationStatus()
Returns the current Airship push notification status.
PushProviderType getPushProviderType()
Gets the PushProviderType corresponding to the current push provider.
String getPushToken()
Gets the push token.
Date[] getQuietTimeInterval()
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
boolean getUserNotificationsEnabled()
Determines whether user-facing push notifications are enabled.
boolean isInQuietTime()
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
boolean isOptIn()
Returns if the application is currently opted in for push.
boolean isPushAvailable()
Determines whether the app is capable of receiving push, meaning whether a FCM or ADM push token is present.
boolean isQuietTimeEnabled()
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
boolean isSoundEnabled()
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
boolean isVibrateEnabled()
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
void removeNotificationActionButtonGroup(String id)
Removes the notification button group under the given name.
void removeNotificationStatusListener(PushNotificationStatusListener listener)
Removes an Airship push notification status listener.
void removePushListener(PushListener listener)
Removes a push listener.
void removePushTokenListener(PushTokenListener listener)
Removes a push token listener.
void setForegroundNotificationDisplayPredicate(Predicate<PushMessage> foregroundDisplayPredicate)
Sets a predicate that determines if a notification should be presented in the foreground or not.
void setNotificationListener(NotificationListener listener)
Sets the notification listener.
void setNotificationProvider(NotificationProvider provider)
Sets the notification provider used to build notifications from a push message

If null, notification will not be displayed.

void setQuietTimeEnabled(boolean enabled)
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
void setQuietTimeInterval(Date startTime, Date endTime)
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
void setSoundEnabled(boolean enabled)
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
void setUserNotificationsEnabled(boolean enabled)
Enables or disables user notifications.
void setVibrateEnabled(boolean enabled)
This method is deprecated. This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.
Protected Methods
void init()
Initialize the manager.
void onAirshipReady(UAirship airship)
Called when airship instance is ready.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String EXTRA_NOTIFICATION_ID

The notification ID extra contains the ID of the notification placed in the NotificationManager by the library.

If a Notification was not created, the extra will not be included.

Constant Value: "com.urbanairship.push.NOTIFICATION_ID"

public static final String EXTRA_NOTIFICATION_TAG

The notification tag extra contains the tag of the notification placed in the NotificationManager by the library.

If a Notification was not created, the extra will not be included.

Constant Value: "com.urbanairship.push.NOTIFICATION_TAG"

Public Methods

public void addNotificationActionButtonGroup (String id, NotificationActionButtonGroup group)

Register a notification action group under the given name.

The provided notification builders will automatically add the actions to the notification when a message is received with a group specified under the EXTRA_INTERACTIVE_TYPE key.

Parameters
id The id of the action group.
group The notification action group.

public void addNotificationActionButtonGroups (Context context, int resId)

Adds notification action button groups from an xml file. Example entry:

<UrbanAirshipActionButtonGroup id="custom_group">
  <UrbanAirshipActionButton
      foreground="true"
      id="yes"
      android:icon="@drawable/ua_ic_notification_button_accept"
      android:label="@string/ua_notification_button_yes"/>
  <UrbanAirshipActionButton
      foreground="false"
      id="no"
      android:icon="@drawable/ua_ic_notification_button_decline"
      android:label="@string/ua_notification_button_no"/>
 </UrbanAirshipActionButtonGroup> 

Parameters
context The application context.
resId The xml resource ID.

public void addNotificationStatusListener (PushNotificationStatusListener listener)

Adds an Airship push notification status listener.

Parameters
listener The listener.

public void addPushListener (PushListener listener)

Adds a push listener.

Parameters
listener The push listener.

public void addPushTokenListener (PushTokenListener listener)

Adds a push token listener.

Parameters
listener The listener.

public boolean areNotificationsOptedIn ()

Checks if notifications are enabled for the app and in the push manager.

Returns
  • true if notifications are opted in, otherwise false.

public Predicate<PushMessage> getForegroundNotificationDisplayPredicate ()

Gets the foreground notification display predicate.

Returns
  • The predicate.

public String getLastReceivedMetadata ()

Returns the send metadata of the last received push.

Returns
  • The send metadata from the last received push, or null if not found.

public NotificationActionButtonGroup getNotificationActionGroup (String id)

Returns the notification action group that is registered under the given name.

Parameters
id The id of the action group.
Returns
  • The notification action group.

public NotificationChannelRegistry getNotificationChannelRegistry ()

Returns the shared notification channel registry.

Returns
  • The NotificationChannelRegistry

public NotificationListener getNotificationListener ()

Gets the notification listener.

Returns
  • The notification listener.

public NotificationProvider getNotificationProvider ()

Gets the notification provider.

Returns
  • The notification provider.

public PushNotificationStatus getPushNotificationStatus ()

Returns the current Airship push notification status.

Returns
  • A status object.

public PushProviderType getPushProviderType ()

Gets the PushProviderType corresponding to the current push provider.

Returns
  • The active PushProviderType.

public String getPushToken ()

Gets the push token.

Returns
  • The push token.

public Date[] getQuietTimeInterval ()

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Returns the Quiet Time interval currently set by the user.

Returns
  • An array of two Date instances, representing the start and end of Quiet Time.

public boolean getUserNotificationsEnabled ()

Determines whether user-facing push notifications are enabled.

Returns
  • true if user push is enabled, false otherwise.

public boolean isInQuietTime ()

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Determines whether we are currently in the middle of "Quiet Time". Returns false if Quiet Time is disabled, and evaluates whether or not the current date/time falls within the Quiet Time interval set by the user.

Returns
  • A boolean indicating whether it is currently "Quiet Time".

public boolean isOptIn ()

Returns if the application is currently opted in for push.

Returns
  • true if opted in for push.

public boolean isPushAvailable ()

Determines whether the app is capable of receiving push, meaning whether a FCM or ADM push token is present.

Returns
  • true if push is available, false otherwise.

public boolean isQuietTimeEnabled ()

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Determines whether "Quiet Time" is enabled.

Returns
  • A boolean indicating whether Quiet Time is enabled.

public boolean isSoundEnabled ()

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Determines whether sound is enabled.

Returns
  • A boolean indicated whether sound is enabled.

public boolean isVibrateEnabled ()

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Determines whether vibration is enabled.

Returns
  • A boolean indicating whether vibration is enabled.

public void removeNotificationActionButtonGroup (String id)

Removes the notification button group under the given name.

Parameters
id The id of the button group to remove.

public void removeNotificationStatusListener (PushNotificationStatusListener listener)

Removes an Airship push notification status listener.

Parameters
listener The listener.

public void removePushListener (PushListener listener)

Removes a push listener.

Parameters
listener The listener.

public void removePushTokenListener (PushTokenListener listener)

Removes a push token listener.

Parameters
listener The listener.

public void setForegroundNotificationDisplayPredicate (Predicate<PushMessage> foregroundDisplayPredicate)

Sets a predicate that determines if a notification should be presented in the foreground or not.

Parameters
foregroundDisplayPredicate The display predicate.

public void setNotificationListener (NotificationListener listener)

Sets the notification listener.

Parameters
listener The listener.

public void setNotificationProvider (NotificationProvider provider)

Sets the notification provider used to build notifications from a push message

If null, notification will not be displayed.

Parameters
provider The notification provider

public void setQuietTimeEnabled (boolean enabled)

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Enables or disables quiet time.

Parameters
enabled A boolean indicating whether quiet time is enabled.

public void setQuietTimeInterval (Date startTime, Date endTime)

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Sets the Quiet Time interval.

Parameters
startTime A Date instance indicating when Quiet Time should start.
endTime A Date instance indicating when Quiet Time should end.

public void setSoundEnabled (boolean enabled)

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Enables or disables sound.

Parameters
enabled A boolean indicating whether sound is enabled.

public void setUserNotificationsEnabled (boolean enabled)

Enables or disables user notifications.

User notifications are push notifications that contain an alert message and are intended to be shown to the user.

This setting is persisted between application starts, so there is no need to call this repeatedly. It is only necessary to call this when a user preference has changed.

Parameters
enabled A boolean indicating whether user push is enabled.

public void setVibrateEnabled (boolean enabled)

This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to use NotificationChannelCompat instead.

Enables or disables vibration.

Parameters
enabled A boolean indicating whether vibration is enabled.

Protected Methods

protected void init ()

Initialize the manager. Called in UAirship during takeoff.

protected void onAirshipReady (UAirship airship)

Called when airship instance is ready.

Parameters
airship The airship instance.