-
public final class BatchNotificationChannelsManagerBatchNotificationChannelsManager manages how Batch interacts with Android 8.0 (API 26). It allows you to control which default notification channel Batch will use, how it is named, or to provide your own channel per notification
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBatchNotificationChannelsManager.ChannelNameProviderInterface describing a channel name provider.
Implementing that interface allows Batch to call you back on locale change, to update yourchannel name translation.
public final classBatchNotificationChannelsManager.StringResChannelNameProviderImplementation of ChannelNameProvider using a String resource to automatically fetchthe right translation.
public interfaceBatchNotificationChannelsManager.NotificationChannelIdInterceptorInterface describing a channel ID interceptor for notifications displayed by Batch
-
Field Summary
Fields Modifier and Type Field Description private BatchNotificationChannelsManager.ChannelNameProviderchannelNameProviderprivate BatchNotificationChannelsManager.NotificationChannelIdInterceptorchannelIdInterceptorpublic final static StringDEFAULT_CHANNEL_ID
-
Method Summary
Modifier and Type Method Description voidsetChannelNameProvider(@Nullable() BatchNotificationChannelsManager.ChannelNameProvider provider)Used to set a channel name provider, allowing you to change Batch's default channel name. voidsetChannelIdInterceptor(@Nullable() BatchNotificationChannelsManager.NotificationChannelIdInterceptor interceptor)Used to set a channel id interceptor, allowing you to override the Channel ID of a notification, per notification. static BatchNotificationChannelsManagerprovide()voidsetChannelIdOverride(@Nullable() String channelId)Overrides the default notification channel that Batch will use for notifications. voidsetChannelName(@NonNull() Context context, @StringRes() int channelNameResourceId)Used to set a channel name provider, allowing you to change Batch's default channel name. static booleanopenSystemChannelSettings(@NonNull() Context context)Opens the notification channel settings system UI for Batch's default channel. static booleanopenSystemChannelSettings(@NonNull() Context context, @NonNull() String channelId)Opens the notification channel settings system UI for the specified channelWill do nothing on API < 26 -
-
Method Detail
-
setChannelNameProvider
void setChannelNameProvider(@Nullable() BatchNotificationChannelsManager.ChannelNameProvider provider)
Used to set a channel name provider, allowing you to change Batch's default channel name.
This is the string that the user will see in their device settings, so you should translate it.Batch will call you back on your provider at least once, to get the channel name, and then willcall you on every locale change, to make sure that the Android OS has the right translation.
If your provider throws an exception, Batch will use its default name.
If you simply want to use a string resource, use setChannelName.
Set to 'null' to remove the provider and use Batch's default one.
-
setChannelIdInterceptor
void setChannelIdInterceptor(@Nullable() BatchNotificationChannelsManager.NotificationChannelIdInterceptor interceptor)
Used to set a channel id interceptor, allowing you to override the Channel ID of a notification, per notification.You will be called on this interceptor before displaying notifications, unless you're in manual mode and don't use Batch to display the notification.
The provider might be called on ANY API Level
If your provider throws an exception, Batch will use its default name.
-
provide
static BatchNotificationChannelsManager provide()
-
setChannelIdOverride
void setChannelIdOverride(@Nullable() String channelId)
Overrides the default notification channel that Batch will use for notifications.By default, Batch will manage its own channel, identified by DEFAULT_CHANNEL_ID.After calling this method with a non-null channelId, Batch will stop trying to register its default channel
Note: Please make sure that you've registered this channel using createNotificationChannel or createNotificationChannelGroup
Set to 'null' to revert to the default channel.
-
setChannelName
void setChannelName(@NonNull() Context context, @StringRes() int channelNameResourceId)
Used to set a channel name provider, allowing you to change Batch's default channel name.
This is the string that the user will see in their device settings, so you should translate it properly.Calling this is the equivalent of calling setChannelNameProvider with a StringResChannelNameProvider instance.
Calling this method will remove any provider set with setChannelNameProvider
-
openSystemChannelSettings
static boolean openSystemChannelSettings(@NonNull() Context context)
Opens the notification channel settings system UI for Batch's default channel.
Will do nothing on API < 26
- Parameters:
context- Your context
-
openSystemChannelSettings
static boolean openSystemChannelSettings(@NonNull() Context context, @NonNull() String channelId)
Opens the notification channel settings system UI for the specified channel
Will do nothing on API < 26
- Parameters:
context- Your context.channelId- The channel to open this.
-
-
-
-