public class WonderPushUserPreferences
extends java.lang.Object
Starting with Android O, you will have to implement Notification Channels. This class helps you in this process.
Read more about Android O Notification Channels.
You must call WonderPush.initialize(Context)
before using this class.
Prior to Android O, the SDK can handle every aspect of the notification.
Starting with Android O, the user is in charge of the importance of notifications,
whether they should vibrate or emit a sound, etc.
In order to ease the transition as well as bring Android O notification channels benefits
to previous versions of Android, use this class to define channels.
The channels and groups defined here will be matched to Android O channels as soon as the
device OS is upgraded. The application is free to manage notification groups and channels
by itself and it needs not make this class aware of them.
Constructor and Description |
---|
WonderPushUserPreferences() |
Modifier and Type | Method and Description |
---|---|
static WonderPushChannel |
getChannel(java.lang.String channelId)
Get a channel.
|
static WonderPushChannelGroup |
getChannelGroup(java.lang.String groupId)
Get a channel group.
|
static java.lang.String |
getDefaultChannelId()
Get the default channel id.
|
static void |
putChannel(WonderPushChannel channel)
Create or update a channel.
|
static void |
putChannelGroup(WonderPushChannelGroup channelGroup)
Create or update a channel group.
|
static void |
removeChannel(java.lang.String channelId)
Remove a channel.
|
static void |
removeChannelGroup(java.lang.String groupId)
Remove a channel group.
|
static void |
setChannelGroups(java.util.Collection<WonderPushChannelGroup> channelGroups)
Create, update and remove channel existing groups to match the given channel groups.
|
static void |
setChannels(java.util.Collection<WonderPushChannel> channels)
Create, update and remove channels to match the given channels.
|
static void |
setDefaultChannelId(java.lang.String id)
Set the default channel id.
|
public static java.lang.String getDefaultChannelId()
The default channel is used when a received notification is not explicitly bound to a channel, and as the default notification channel from Android O, as they are mandatory.
The default channel is initially created to an empty WonderPushChannel
,
meaning that the SDK won't apply any changes to the notifications (prior to Android O).
public static void setDefaultChannelId(java.lang.String id)
This function does not enforce the existence of the given channel until a notification is to be posted to the default channel. This way you are free to call this function either before or after creating the given channel, either using this class or directly using Android O APIs.
id
- The identifier of the default channel.public static WonderPushChannelGroup getChannelGroup(java.lang.String groupId)
groupId
- The identifier of the channel group to get.null
otherwise, in particular if an Android android.app.android.app.NotificationChannelGroup
exists but has not been registered with this class.public static void removeChannelGroup(java.lang.String groupId)
Remove a channel group both from this class registry and from Android.
groupId
- The identifier of the channel group to remove.public static void putChannelGroup(WonderPushChannelGroup channelGroup)
Creates or updates a channel group both in this class registry and in Android.
channelGroup
- The channel group to create or update.public static void setChannelGroups(java.util.Collection<WonderPushChannelGroup> channelGroups)
Creates, updates and removes channel groups both in this class registry and in Android.
Any non listed, previously existing channel group will be removed.
channelGroups
- The channel groups to create or update.
Any non listed, previously existing channel group will be removed.public static WonderPushChannel getChannel(java.lang.String channelId)
channelId
- The identifier of the channel to get.null
otherwise, in particular if an Android android.app.android.app.NotificationChannel
exists but has not been registered with this class.public static void removeChannel(java.lang.String channelId)
Remove a channel both from this class registry and from Android.
channelId
- The identifier of the channel to remove.public static void putChannel(WonderPushChannel channel)
Creates or updates a channel both in this class registry and in Android.
channel
- The channel to create or update.public static void setChannels(java.util.Collection<WonderPushChannel> channels)
Creates, updates and removes channels both in this class registry and in Android.
Any non listed, previously existing channel will be removed.
channels
- The channels to create or update.
Any non listed, previously existing channel will be removed.