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.
Public Methods
void addNotificationActionButtonGroup(String id, NotificationActionButtonGroup group)
Register a notification action group under the given name.
TagGroupsEditor editTagGroups()
Edit the channel tag groups.
TagEditor editTags()
Edits channel Tags.
void enableChannelCreation()
Enables channel creation if channel creation has been delayed.
String getAlias()
Returns the current alias for this application's channel.
String getChannelId()
Get the Channel ID
boolean getChannelTagRegistrationEnabled()
Determines whether tags are enabled on the device.
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.
NotificationFactory getNotificationFactory()
Returns the current notification factory.
boolean getPushTokenRegistrationEnabled()
Determines whether the GCM token or ADM ID is sent during channel registration.
Date[] getQuietTimeInterval()
Returns the Quiet Time interval currently set by the user.
String getRegistrationToken()
Gets the GCM Instance ID or ADM ID token.
Set<String> getTags()
Returns the current set of tags.
boolean getUserNotificationsEnabled()
Determines whether user-facing push notifications are enabled.
boolean isInQuietTime()
Determines whether we are currently in the middle of "Quiet Time".
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 GCM or ADM registration ID is present.
boolean isPushEnabled()
Determines whether push is enabled.
boolean isQuietTimeEnabled()
Determines whether "Quiet Time" is enabled.
boolean isSoundEnabled()
Determines whether sound is enabled.
boolean isVibrateEnabled()
Determines whether vibration is enabled.
void removeNotificationActionButtonGroup(String id)
Removes the notification button group under the given name.
void setAlias(String alias)
Set the alias for the channel and update the server.
void setAliasAndTags(String alias, Set<String> tags)
Sets both the alias and tags for this channel and updates the server.
void setChannelTagRegistrationEnabled(boolean enabled)
Sets whether tags are enabled on the device.
void setNotificationFactory(NotificationFactory factory)
Sets the notification factory used when push notifications are received.
void setPushEnabled(boolean enabled)
Enables or disables push notifications.
void setPushTokenRegistrationEnabled(boolean enabled)
Sets whether the GCM token or ADM ID is sent during channel registration.
void setQuietTimeEnabled(boolean enabled)
Sets the quiet time enabled.
void setQuietTimeInterval(Date startTime, Date endTime)
Sets the Quiet Time interval.
void setSoundEnabled(boolean enabled)
Enables or disables sound.
void setTags(Set<String> tags)
Set tags for the channel and update the server.
void setUserNotificationsEnabled(boolean enabled)
Enables or disables user notifications.
void setVibrateEnabled(boolean enabled)
Enables or disables vibration.
void updateRegistration()
Update registration.
Protected Methods
void init()
Initialize the manager.
int onPerformJob(UAirship airship, Job job)
Called when a scheduled Job is ready to perform.
[Expand]
Inherited Methods
From class com.urbanairship.AirshipComponent
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 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 TagGroupsEditor editTagGroups ()

Edit the channel tag groups.

Returns

public TagEditor editTags ()

Edits channel Tags.

Returns

public void enableChannelCreation ()

Enables channel creation if channel creation has been delayed.

This setting is persisted between application starts, so there is no need to call this repeatedly. It is only necessary to call this when channelCreationDelayEnabled has been set to true in the airship config.

public String getAlias ()

Returns the current alias for this application's channel.

Returns
  • The string alias, or null if one is not set.

public String getChannelId ()

Get the Channel ID

Returns
  • A Channel ID string

public boolean getChannelTagRegistrationEnabled ()

Determines whether tags are enabled on the device. If false, no locally specified tags will be sent to the server during registration. The default value is true.

Returns
  • true if tags are enabled on the device, false otherwise.

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 NotificationFactory getNotificationFactory ()

Returns the current notification factory.

Returns
  • The current notification factory.

public boolean getPushTokenRegistrationEnabled ()

Determines whether the GCM token or ADM ID is sent during channel registration. If false, the app will not be able to receive push notifications. The default value is true.

Returns
  • true if the GCM token or ADM ID is sent during channel registration, false otherwise.

public Date[] getQuietTimeInterval ()

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 String getRegistrationToken ()

Gets the GCM Instance ID or ADM ID token.

Returns
  • The GCM or ADM token.

public Set<String> getTags ()

Returns the current set of tags.

An empty set indicates that no tags are set on this channel.

Returns
  • The current set of tags.

public boolean getUserNotificationsEnabled ()

Determines whether user-facing push notifications are enabled.

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

public boolean isInQuietTime ()

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 GCM or ADM registration ID is present.

Returns
  • true if push is available, false otherwise.

public boolean isPushEnabled ()

Determines whether push is enabled.

Returns
  • true if push is enabled, false otherwise. This defaults to true, and must be explicitly set by the app.

public boolean isQuietTimeEnabled ()

Determines whether "Quiet Time" is enabled.

Returns
  • A boolean indicating whether Quiet Time is enabled.

public boolean isSoundEnabled ()

Determines whether sound is enabled.

Returns
  • A boolean indicated whether sound is enabled.

public boolean isVibrateEnabled ()

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 setAlias (String alias)

Set the alias for the channel and update the server.

If you are setting both the alias and tags at the same time, you should use setAliasAndTags(String, Set) to avoid making an extra network call.

Refer to the Alias for more information on the use of aliases.

Parameters
alias The alias, null to remove

public void setAliasAndTags (String alias, Set<String> tags)

Sets both the alias and tags for this channel and updates the server.

Tags should be URL-safe with a length greater than 0 and less than 127 characters. If your tag includes whitespace or special characters, we recommend URL encoding the string.

Parameters
alias The desired alias, null to remove
tags The desired set of tags, must be non-null

public void setChannelTagRegistrationEnabled (boolean enabled)

Sets whether tags are enabled on the device. The default value is true. If false, no locally specified tags will be sent to the server during registration.

Parameters
enabled A boolean indicating whether tags are enabled on the device.

public void setNotificationFactory (NotificationFactory factory)

Sets the notification factory used when push notifications are received.

Specify a notification factory here to customize the display of a push notification's Custom Expanded Views in the Android Notification Manager.

If null, push notifications will not be displayed by the library.

Parameters
factory The notification factory

public void setPushEnabled (boolean enabled)

Enables or disables push notifications.

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 push is enabled.

public void setPushTokenRegistrationEnabled (boolean enabled)

Sets whether the GCM token or ADM ID is sent during channel registration. If false, the app will not be able to receive push notifications.

Parameters
enabled A boolean indicating whether the GCM token or ADM ID is sent during channel registration.

public void setQuietTimeEnabled (boolean enabled)

Sets the quiet time enabled.

Parameters
enabled A boolean indicating whether quiet time is enabled.

public void setQuietTimeInterval (Date startTime, Date endTime)

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)

Enables or disables sound.

Parameters
enabled A boolean indicating whether sound is enabled.

public void setTags (Set<String> tags)

Set tags for the channel and update the server.

Tags should be URL-safe with a length greater than 0 and less than 127 characters. If your tag includes whitespace or special characters, we recommend URL encoding the string.

To clear the current set of tags, pass an empty set to this method.

If you are setting both the alias and tags at the same time, you should use setAliasAndTags(String, Set) to avoid making an extra network call.

Refer to the Tag API for more information.

Parameters
tags A set of tag strings.

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)

Enables or disables vibration.

Parameters
enabled A boolean indicating whether vibration is enabled.

public void updateRegistration ()

Update registration.

Protected Methods

protected void init ()

Initialize the manager. Called in UAirship during takeoff.

protected int onPerformJob (UAirship airship, Job job)

Called when a scheduled Job is ready to perform.

Parameters
airship The airship instance.
job The scheduled job.
Returns
  • The result of the job.