java.lang.Object | ||
↳ | com.urbanairship.AirshipComponent | |
↳ | com.urbanairship.push.PushManager |
This class is the primary interface for customizing the display and behavior of incoming push notifications.
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
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 |
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.
| ||||||||||
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.
| ||||||||||
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 |
isPushEnabled()
This method is deprecated.
Enable/disable by enabling
FEATURE_PUSH in PrivacyManager .
This will call through to the privacy manager.
| ||||||||||
boolean |
isPushTokenRegistrationEnabled()
This method is deprecated.
Check if
FEATURE_PUSH is enabled in the PrivacyManager .
| ||||||||||
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 |
removePushListener(PushListener listener)
Removes a push listener.
| ||||||||||
void |
removePushTokenListener(PushTokenListener listener)
Removes a push token listener.
| ||||||||||
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 | ||||||||||
void |
setPushEnabled(boolean enabled)
This method is deprecated.
Enable/disable by enabling
FEATURE_PUSH in PrivacyManager .
This will call through to the privacy manager.
| ||||||||||
void |
setPushTokenRegistrationEnabled(boolean enabled)
This method is deprecated.
Enable/disable
FEATURE_PUSH in the PrivacyManager .
| ||||||||||
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.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
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.
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.
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.
id | The id of the action group. |
---|---|
group | The notification action group. |
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>
context | The application context. |
---|---|
resId | The xml resource ID. |
Adds a push listener.
listener | The push listener. |
---|
Adds a push token listener.
listener | The listener. |
---|
Checks if notifications are enabled for the app and in the push manager.
true
if notifications are opted in, otherwise false
.
Returns the send metadata of the last received push.
Returns the notification action group that is registered under the given name.
id | The id of the action group. |
---|
Returns the shared notification channel registry.
Gets the notification listener.
Gets the notification provider.
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.
Determines whether user-facing push notifications are enabled.
true
if user push is enabled, false
otherwise.
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 if the application is currently opted in for push.
true
if opted in for push.
Determines whether the app is capable of receiving push, meaning whether a FCM or ADM push token is present.
true
if push is available, false
otherwise.
This method is deprecated.
Enable/disable by enabling FEATURE_PUSH
in PrivacyManager
.
This will call through to the privacy manager.
Determines whether push is enabled.
true
if push is enabled, false
otherwise.
This defaults to true, and must be explicitly set by the app.
This method is deprecated.
Check if FEATURE_PUSH
is enabled in the PrivacyManager
.
Determines whether the push token is sent during channel registration.
If false
, the app will not be able to receive push notifications.
true
if the push token is sent during channel registration,
false
otherwise.
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.
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Determines whether sound is enabled.
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Determines whether vibration is enabled.
Removes the notification button group under the given name.
id | The id of the button group to remove. |
---|
Removes a push listener.
listener | The listener. |
---|
Removes a push token listener.
listener | The listener. |
---|
Sets the notification listener.
listener | The listener. |
---|
Sets the notification provider used to build notifications from a push message
If null
, notification will not be displayed.
provider | The notification provider |
---|
This method is deprecated.
Enable/disable by enabling FEATURE_PUSH
in PrivacyManager
.
This will call through to the privacy manager.
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.
enabled | A boolean indicating whether push is enabled. |
---|
This method is deprecated.
Enable/disable FEATURE_PUSH
in the PrivacyManager
.
Sets whether the push token is sent during channel registration.
If false
, the app will not be able to receive push notifications.
enabled | A boolean indicating whether the push token is sent during channel registration. |
---|
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Enables or disables quiet time.
enabled | A boolean indicating whether quiet time is enabled. |
---|
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Sets the Quiet Time interval.
startTime | A Date instance indicating when Quiet Time should start. |
---|---|
endTime | A Date instance indicating when Quiet Time should end. |
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Enables or disables sound.
enabled | A boolean indicating whether sound is 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.
enabled | A boolean indicating whether user push is enabled. |
---|
This method is deprecated.
This setting does not work on Android O+. Applications are encouraged to
use NotificationChannelCompat
instead.
Enables or disables vibration.
enabled | A boolean indicating whether vibration is enabled. |
---|