Public Method Summary
AndroidNotification.Builder |
addAllBodyLocalizationArgs(List<String> args)
Adds a list of resource keys that will be used in place of the format specifiers in
bodyLocKey . |
AndroidNotification.Builder |
addAllTitleLocalizationArgs(List<String> args)
Adds a list of resource keys that will be used in place of the format specifiers in
titleLocKey . |
AndroidNotification.Builder |
addBodyLocalizationArg(String arg)
Adds a resource key string that will be used in place of the format specifiers in
bodyLocKey . |
AndroidNotification.Builder |
addTitleLocalizationArg(String arg)
Adds a resource key string that will be used in place of the format specifiers in
titleLocKey . |
AndroidNotification |
build()
Creates a new
AndroidNotification instance from the parameters set on this builder. |
AndroidNotification.Builder |
setBody(String body)
Sets the body of the Android notification.
|
AndroidNotification.Builder |
setBodyLocalizationKey(String bodyLocKey)
Sets the key of the body string in the app's string resources to use to localize the body
text.
|
AndroidNotification.Builder |
setChannelId(String channelId)
Sets the Android notification channel ID (new in Android O).
|
AndroidNotification.Builder |
setClickAction(String clickAction)
Sets the action associated with a user click on the notification.
|
AndroidNotification.Builder |
setColor(String color)
Sets the notification icon color.
|
AndroidNotification.Builder |
setDefaultLightSettings(boolean defaultLightSettings)
Sets the whether to use the default light settings.
|
AndroidNotification.Builder |
setDefaultSound(boolean defaultSound)
Sets the whether to use the default sound.
|
AndroidNotification.Builder |
setDefaultVibrateTimings(boolean defaultVibrateTimings)
Sets the whether to use the default vibration timings.
|
AndroidNotification.Builder |
setEventTimeInMillis(long eventTimeInMillis)
For notifications that inform users about events with an absolute time reference, sets
the time that the event in the notification occurred in milliseconds.
|
AndroidNotification.Builder |
setIcon(String icon)
Sets the icon of the Android notification.
|
AndroidNotification.Builder |
setImage(String imageUrl)
Sets the URL of the image that is going to be displayed in the notification.
|
AndroidNotification.Builder |
setLightSettings(LightSettings lightSettings)
Sets the settings to control the notification's LED blinking rate and color if LED is
available on the device.
|
AndroidNotification.Builder |
setLocalOnly(boolean localOnly)
Sets whether or not this notification is relevant only to the current device.
|
AndroidNotification.Builder |
setNotificationCount(int notificationCount)
Sets the number of items this notification represents.
|
AndroidNotification.Builder |
setPriority(AndroidNotification.Priority priority)
Sets the relative priority for this notification.
|
AndroidNotification.Builder |
setSound(String sound)
Sets the sound to be played when the device receives the notification.
|
AndroidNotification.Builder |
setSticky(boolean sticky)
Sets the sticky flag.
|
AndroidNotification.Builder |
setTag(String tag)
Sets the notification tag.
|
AndroidNotification.Builder |
setTicker(String ticker)
Sets the "ticker" text, which is sent to accessibility services.
|
AndroidNotification.Builder |
setTitle(String title)
Sets the title of the Android notification.
|
AndroidNotification.Builder |
setTitleLocalizationKey(String titleLocKey)
Sets the key of the title string in the app's string resources to use to localize the title
text.
|
AndroidNotification.Builder |
setVibrateTimingsInMillis(long[] vibrateTimingsInMillis)
Sets a list of vibration timings in milliseconds in the array to use.
|
AndroidNotification.Builder |
Inherited Method Summary
Public Methods
public AndroidNotification.Builder addAllBodyLocalizationArgs (List<String> args)
Adds a list of resource keys that will be used in place of the format specifiers in
bodyLocKey
.
Parameters
args | List of resource key strings. |
---|
Returns
- This builder.
public AndroidNotification.Builder addAllTitleLocalizationArgs (List<String> args)
Adds a list of resource keys that will be used in place of the format specifiers in
titleLocKey
.
Parameters
args | List of resource key strings. |
---|
Returns
- This builder.
public AndroidNotification.Builder addBodyLocalizationArg (String arg)
Adds a resource key string that will be used in place of the format specifiers in
bodyLocKey
.
Parameters
arg | Resource key string. |
---|
Returns
- This builder.
public AndroidNotification.Builder addTitleLocalizationArg (String arg)
Adds a resource key string that will be used in place of the format specifiers in
titleLocKey
.
Parameters
arg | Resource key string. |
---|
Returns
- This builder.
public AndroidNotification build ()
Creates a new AndroidNotification
instance from the parameters set on this builder.
Returns
- A new
AndroidNotification
instance.
Throws
IllegalArgumentException | If any of the parameters set on the builder are invalid. |
---|
public AndroidNotification.Builder setBody (String body)
Sets the body of the Android notification. When provided, overrides the body set
via Notification
.
Parameters
body | Body of the notification. |
---|
Returns
- This builder.
public AndroidNotification.Builder setBodyLocalizationKey (String bodyLocKey)
Sets the key of the body string in the app's string resources to use to localize the body text.
Parameters
bodyLocKey | Resource key string. |
---|
Returns
- This builder.
public AndroidNotification.Builder setChannelId (String channelId)
Sets the Android notification channel ID (new in Android O). The app must create a channel with this channel ID before any notification with this channel ID is received. If you don't send this channel ID in the request, or if the channel ID provided has not yet been created by the app, FCM uses the channel ID specified in the app manifest.
Parameters
channelId | The notification's channel ID. |
---|
Returns
- This builder.
public AndroidNotification.Builder setClickAction (String clickAction)
Sets the action associated with a user click on the notification. If specified, an activity with a matching Intent Filter is launched when a user clicks on the notification.
Parameters
clickAction | Click action name. |
---|
Returns
- This builder.
public AndroidNotification.Builder setColor (String color)
Sets the notification icon color.
Parameters
color | Color specified in the #rrggbb format. |
---|
Returns
- This builder.
public AndroidNotification.Builder setDefaultLightSettings (boolean defaultLightSettings)
Sets the whether to use the default light settings. If set to true, use the Android
framework's default LED light settings for the notification. Default values are
specified in config.xml. If default_light_settings
is set to true and
light_settings
is also set, the user-specified light_settings
is used
instead of the default value.
Parameters
defaultLightSettings | The flag indicating whether to use the default light settings |
---|
Returns
- This builder.
public AndroidNotification.Builder setDefaultSound (boolean defaultSound)
Sets the whether to use the default sound. If set to true, use the Android framework's default sound for the notification. Default values are specified in config.xml.
Parameters
defaultSound | The flag indicating whether to use the default sound |
---|
Returns
- This builder.
public AndroidNotification.Builder setDefaultVibrateTimings (boolean defaultVibrateTimings)
Sets the whether to use the default vibration timings. If set to true, use the Android
framework's default vibrate pattern for the notification. Default values are specified
in config.xml
. If default_vibrate_timings
is set to true and
vibrate_timings
is also set, the default value is used instead of the
user-specified vibrate_timings
.
Parameters
defaultVibrateTimings | The flag indicating whether to use the default vibration timings |
---|
Returns
- This builder.
public AndroidNotification.Builder setEventTimeInMillis (long eventTimeInMillis)
For notifications that inform users about events with an absolute time reference, sets the time that the event in the notification occurred in milliseconds. Notifications in the panel are sorted by this time. The time is formatted in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z". Note that since the time is in milliseconds, the last section of the time representation always has 6 leading zeros.
Parameters
eventTimeInMillis | The event time in milliseconds |
---|
Returns
- This builder.
public AndroidNotification.Builder setIcon (String icon)
Sets the icon of the Android notification.
Parameters
icon | Icon resource for the notification. |
---|
Returns
- This builder.
public AndroidNotification.Builder setImage (String imageUrl)
Sets the URL of the image that is going to be displayed in the notification. When provided,
overrides the imageUrl set via Notification
.
Parameters
imageUrl | URL of the image that is going to be displayed in the notification. |
---|
Returns
- This builder.
public AndroidNotification.Builder setLightSettings (LightSettings lightSettings)
Sets the settings to control the notification's LED blinking rate and color if LED is available on the device. The total blinking time is controlled by the OS.
Parameters
lightSettings | The light settings to use |
---|
Returns
- This builder.
public AndroidNotification.Builder setLocalOnly (boolean localOnly)
Sets whether or not this notification is relevant only to the current device. Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this notification not be bridged.
Parameters
localOnly | The "local only" flag |
---|
Returns
- This builder.
public AndroidNotification.Builder setNotificationCount (int notificationCount)
Sets the number of items this notification represents. May be displayed as a badge count for launchers that support badging. If not invoked then notification count is left unchanged. For example, this might be useful if you're using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages. If zero or unspecified, systems that support badging use the default, which is to increment a number displayed on the long-press menu each time a new notification arrives.
Parameters
notificationCount | Zero or positive value. Zero indicates leave unchanged. |
---|
Returns
- This builder.
public AndroidNotification.Builder setPriority (AndroidNotification.Priority priority)
Sets the relative priority for this notification. Priority is an indication of how much of the user's attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification.
Parameters
priority | The priority value, one of the values in {MIN, LOW, DEFAULT, HIGH, MAX} |
---|
Returns
- This builder.
public AndroidNotification.Builder setSound (String sound)
Sets the sound to be played when the device receives the notification.
Parameters
sound | File name of the sound resource or "default". |
---|
Returns
- This builder.
public AndroidNotification.Builder setSticky (boolean sticky)
Sets the sticky flag. When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to true, the notification persists even when the user clicks it.
Parameters
sticky | The sticky flag |
---|
Returns
- This builder.
public AndroidNotification.Builder setTag (String tag)
Sets the notification tag. This is an identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification.
Parameters
tag | Notification tag. |
---|
Returns
- This builder.
public AndroidNotification.Builder setTicker (String ticker)
Sets the "ticker" text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the text that is displayed in the status bar when the notification first arrives.
Parameters
ticker | Ticker name. |
---|
Returns
- This builder.
public AndroidNotification.Builder setTitle (String title)
Sets the title of the Android notification. When provided, overrides the title set
via Notification
.
Parameters
title | Title of the notification. |
---|
Returns
- This builder.
public AndroidNotification.Builder setTitleLocalizationKey (String titleLocKey)
Sets the key of the title string in the app's string resources to use to localize the title text.
Parameters
titleLocKey | Resource key string. |
---|
Returns
- This builder.
public AndroidNotification.Builder setVibrateTimingsInMillis (long[] vibrateTimingsInMillis)
Sets a list of vibration timings in milliseconds in the array to use. The first value in the
array indicates the duration to wait before turning the vibrator on. The next value
indicates the duration to keep the vibrator on. Subsequent values alternate between
duration to turn the vibrator off and to turn the vibrator on. If vibrate_timings
is set and default_vibrate_timings
is set to true, the default value is used instead
of the user-specified vibrate_timings
.
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
Parameters
vibrateTimingsInMillis | List of vibration time in milliseconds |
---|
Returns
- This builder.
public AndroidNotification.Builder setVisibility (AndroidNotification.Visibility visibility)
Sets the visibility of this notification.
Parameters
visibility | The visibility value. one of the values in {PRIVATE, PUBLIC, SECRET} |
---|
Returns
- This builder.