Class WonderPushChannel
- All Implemented Interfaces:
Cloneable
This class mimicks the NotificationChannel
class to permit
exposing its benefits to devices prior to Android O.
Contrary to the latter, this class permits to override only a few aspects of the notification.
It also contains some additions that may no longer be available under Android O where the user
is in full control of these settings, such as preventing a notification that usually makes a
sound or vibrates to vibrate while the device is in silent mode.
Some feature like the color should remain configurable using this class under Android O.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
Whether or not notifications posted to this channel can bypass the Do Not DisturbNotificationManager.INTERRUPTION_FILTER_PRIORITY
mode.getColor()
Returns the color to impose on all notifications posted to this channel.Returns the user visible description of this channel.Returns what group this channel belongs to.getId()
Returns the id of this channel.Returns the user specified importance for notifications posted to this channel.Sets the notification light color for notifications posted to this channel, if lights are enabled on this channel and the device supports that feature.Returns whether notifications posted to this channel trigger notification lights.Returns whether notifications posted to this channel should be local to this device.Returns whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.getName()
Returns the user visible name of this channel.Returns whether notifications posted to this channel can appear as badges in a Launcher application.getSound()
Returns whether a sound should be played for notifications posted to this channel.android.net.Uri
Returns the notification sound for this channel.Returns whether notifications posted to this channel always vibrate.Returns whether notifications posted to this channel vibrate if the device is in silent mode.long[]
Returns the vibration pattern for notifications posted to this channel.int
hashCode()
setBypassDnd
(Boolean bypassDnd) Sets whether or not notifications posted to this channel can interrupt the user inNotificationManager.INTERRUPTION_FILTER_PRIORITY
mode.Sets the color to impose on all notifications posted to this channel.setDescription
(String description) Sets the user visible description of this channel.setImportance
(Integer importance) Sets the level of interruption of this notification channel.setLightColor
(Integer lightColor) Returns the notification light color for notifications posted to this channel.Sets whether notifications posted to this channel should display notification lights, on devices that support that feature.setLocalOnly
(Boolean localOnly) Sets whether notifications posted to this channel should be local to this device.setLockscreenVisibility
(Integer lockscreenVisibility) Sets whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form.Sets the user visible name of this channel.setShowBadge
(Boolean showBadge) Sets whether notifications posted to this channel can appear as application icon badges in a Launcher.Sets whether a sound should be played for notifications posted to this channel.setSoundUri
(android.net.Uri soundUri) Sets the sound that should be played for notifications posted to this channel and its audio attributes.setVibrate
(Boolean vibrate) Sets whether notification posted to this channel should vibrate.setVibrateInSilentMode
(Boolean vibrateInSilentMode) Sets whether notifications posted to this channel vibrate if the device is in silent mode.setVibrationPattern
(long[] vibrationPattern) Sets the vibration pattern for notifications posted to this channel.toString()
-
Constructor Details
-
WonderPushChannel
Create a notification channel.- Parameters:
id
- The id of the channel. Must be unique per package. The value may be truncated if it is too long.groupId
- The id of a channel group. You should create the group prior to creating this channel.- See Also:
-
-
Method Details
-
clone
- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
toString
-
getId
Returns the id of this channel.- See Also:
-
getGroupId
Returns what group this channel belongs to. This is used only for visually grouping channels in the UI. Can benull
.- Returns:
- The id of the group this channel belongs to, if any.
- See Also:
-
getName
Returns the user visible name of this channel.- See Also:
-
setName
Sets the user visible name of this channel. The recommended maximum length is 40 characters; the value may be truncated if it is too long.- Parameters:
name
- The user visible name of this channel.- Returns:
- The channel object for chaining setters.
- See Also:
-
getDescription
Returns the user visible description of this channel.- Returns:
- The user visible description of this channel.
- See Also:
-
setDescription
Sets the user visible description of this channel. The recommended maximum length is 300 characters; the value may be truncated if it is too long.- Parameters:
description
- The user visible description of this channel.- Returns:
- The channel object for chaining setters.
- See Also:
-
getBypassDnd
Whether or not notifications posted to this channel can bypass the Do Not DisturbNotificationManager.INTERRUPTION_FILTER_PRIORITY
mode.- Returns:
- whether or not notifications posted to this channel can bypass the Do Not Disturb
NotificationManager.INTERRUPTION_FILTER_PRIORITY
mode.
-
setBypassDnd
Sets whether or not notifications posted to this channel can interrupt the user inNotificationManager.INTERRUPTION_FILTER_PRIORITY
mode. Only modifiable by the system and notification ranker.- Parameters:
bypassDnd
- whether or not notifications posted to this channel can interrupt the user inNotificationManager.INTERRUPTION_FILTER_PRIORITY
mode.- Returns:
- The channel object for chaining setters.
-
getShowBadge
Returns whether notifications posted to this channel can appear as badges in a Launcher application. Note that badging may be disabled for other reasons.- Returns:
- whether notifications posted to this channel can appear as badges in a Launcher application. Note that badging may be disabled for other reasons.
-
setShowBadge
Sets whether notifications posted to this channel can appear as application icon badges in a Launcher.- Parameters:
showBadge
- true if badges should be allowed to be shown.- Returns:
- The channel object for chaining setters.
-
getImportance
Returns the user specified importance for notifications posted to this channel. Example:NotificationManager.IMPORTANCE_DEFAULT
- Returns:
- The user specified importance for notifications posted to this channel.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setImportance
Sets the level of interruption of this notification channel. Example:NotificationManager.IMPORTANCE_DEFAULT
- Parameters:
importance
- The level of interruption of this notification channel. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getLights
Returns whether notifications posted to this channel trigger notification lights.- Returns:
- Whether notifications posted to this channel trigger notification lights.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setLights
Sets whether notifications posted to this channel should display notification lights, on devices that support that feature.- Parameters:
lights
- Whether notifications posted to this channel should display notification lights Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getVibrate
Returns whether notifications posted to this channel always vibrate.- Returns:
- Whether notifications posted to this channel always vibrate.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setVibrate
Sets whether notification posted to this channel should vibrate. The vibration pattern can be set withsetVibrationPattern(long[])
.- Parameters:
vibrate
- Whether notification posted to this channel should vibrate. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getVibrationPattern
public long[] getVibrationPattern()Returns the vibration pattern for notifications posted to this channel.- Returns:
- The vibration pattern for notifications posted to this channel.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setVibrationPattern
Sets the vibration pattern for notifications posted to this channel.- Parameters:
vibrationPattern
- The vibration pattern for notifications posted to this channel. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getLightColor
Sets the notification light color for notifications posted to this channel, if lights are enabled on this channel and the device supports that feature.- Returns:
- The notification light color for notifications posted to this channel
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setLightColor
Returns the notification light color for notifications posted to this channel.- Parameters:
lightColor
- The notification light color for notifications posted to this channel. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getLockscreenVisibility
Returns whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.- Returns:
- Whether or not notifications posted to this channel are shown on the lockscreen in full or redacted form.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setLockscreenVisibility
Sets whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form. Example:Notification.VISIBILITY_PUBLIC
.- Parameters:
lockscreenVisibility
- Whether notifications posted to this channel appear on the lockscreen or not, and if so, whether they appear in a redacted form. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getSound
Returns whether a sound should be played for notifications posted to this channel.- Returns:
- Whether a sound should be played for notifications posted to this channel.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setSound
Sets whether a sound should be played for notifications posted to this channel.- Parameters:
sound
- Whether a sound should be played for notifications posted to this channel. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getSoundUri
public android.net.Uri getSoundUri()Returns the notification sound for this channel.- Returns:
- The notification sound for this channel.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setSoundUri
Sets the sound that should be played for notifications posted to this channel and its audio attributes. Notification channels with an importance of at leastNotificationManager.IMPORTANCE_DEFAULT
should have a sound.- Parameters:
soundUri
- The sound that should be played for notifications posted to this channel. You can useSettings.System.DEFAULT_NOTIFICATION_URI
to use the default notification sound. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getVibrateInSilentMode
Returns whether notifications posted to this channel vibrate if the device is in silent mode.This is a WonderPush addition.
The primary use of this flag is to permit notifications with sound and vibration in normal mode but prevent it from vibrating in all cases in silent mode.
- Returns:
- Whether notifications posted to this channel vibrate if the device is in silent mode.
Returns
null
if this setting does not override the received notifications setting.
-
setVibrateInSilentMode
Sets whether notifications posted to this channel vibrate if the device is in silent mode.This is a WonderPush addition.
The primary use of this flag is to permit notifications with sound and vibration in normal mode but prevent it from vibrating in all cases in silent mode.
Note: You can control this setting irrespective of the fact that a given notification should vibrate a make a sound in normal mode.
- Parameters:
vibrateInSilentMode
- Whether notifications posted to this channel vibrate if the device is in silent mode. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
-
getColor
Returns the color to impose on all notifications posted to this channel.This is independent of Android O notification channels and should continue to work under Android O.
- Returns:
- The color to impose on all notifications posted to this channel.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setColor
Sets the color to impose on all notifications posted to this channel.This is independent of Android O notification channels and should continue to work under Android O.
- Parameters:
color
- The color to impose on all notifications posted to this channel. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-
getLocalOnly
Returns whether notifications posted to this channel should be local to this device.This is independent of Android O notification channels and should continue to work under Android O.
- Returns:
- Whether notifications posted to this channel should be local to this device.
Returns
null
if this setting does not override the received notifications setting. - See Also:
-
setLocalOnly
Sets whether notifications posted to this channel should be local to this device.This is independent of Android O notification channels and should continue to work under Android O.
- Parameters:
localOnly
- Whether notifications posted to this channel should be local to this device. Usenull
to not override the received notifications setting.- Returns:
- The channel object for chaining setters.
- See Also:
-