Class WonderPushUserPreferences
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.
If not using automatic initialization, make sure to 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic WonderPushChannel
getChannel
(String channelId) Get a channel.static WonderPushChannelGroup
getChannelGroup
(String groupId) Get a channel group.static String
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
(String channelId) Remove a channel.static void
removeChannelGroup
(String groupId) Remove a channel group.static void
setChannelGroups
(Collection<WonderPushChannelGroup> channelGroups) Create, update and remove channel existing groups to match the given channel groups.static void
setChannels
(Collection<WonderPushChannel> channels) Create, update and remove channels to match the given channels.static void
Set the default channel id.
-
Constructor Details
-
WonderPushUserPreferences
public WonderPushUserPreferences()
-
-
Method Details
-
getDefaultChannelId
Get the default channel id.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).- Returns:
- The default channel id.
-
setDefaultChannelId
Set the default channel 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.
- Parameters:
id
- The identifier of the default channel.
-
getChannelGroup
Get a channel group.- Parameters:
groupId
- The identifier of the channel group to get.- Returns:
- The channel group, if it has previously been created using this class,
null
otherwise, in particular if an AndroidNotificationChannelGroup
exists but has not been registered with this class.
-
removeChannelGroup
Remove a channel group.Remove a channel group both from this class registry and from Android.
- Parameters:
groupId
- The identifier of the channel group to remove.
-
putChannelGroup
Create or update a channel group.Creates or updates a channel group both in this class registry and in Android.
- Parameters:
channelGroup
- The channel group to create or update.
-
setChannelGroups
Create, update and remove channel existing groups to match the given channel groups.Creates, updates and removes channel groups both in this class registry and in Android.
Any non listed, previously existing channel group will be removed.
- Parameters:
channelGroups
- The channel groups to create or update. Any non listed, previously existing channel group will be removed.
-
getChannel
Get a channel.- Parameters:
channelId
- The identifier of the channel to get.- Returns:
- The channel, if it has previously been created using this class,
null
otherwise, in particular if an AndroidNotificationChannel
exists but has not been registered with this class.
-
removeChannel
Remove a channel.Remove a channel both from this class registry and from Android.
- Parameters:
channelId
- The identifier of the channel to remove.
-
putChannel
Create or update a channel.Creates or updates a channel both in this class registry and in Android.
- Parameters:
channel
- The channel to create or update.
-
setChannels
Create, update and remove channels to match the given channels.Creates, updates and removes channels both in this class registry and in Android.
Any non listed, previously existing channel will be removed.
- Parameters:
channels
- The channels to create or update. Any non listed, previously existing channel will be removed.
-