Package com.batch.android
Class BatchNotificationInterceptor
java.lang.Object
com.batch.android.BatchNotificationInterceptor
Abstract class describing a notification interceptor.
An interceptor's job is to override some aspects of a notification that Batch wants to display. See the various methods to see what you can override.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionandroidx.core.app.NotificationCompat.Builder
getPushNotificationCompatBuilder
(Context context, androidx.core.app.NotificationCompat.Builder defaultBuilder, Bundle pushIntentExtras, int notificationId) Get the builder instance used to generate the notification.
If you're basing your builder on defaultBuilder, some methods might have undefined behaviour as Batch already calls many of them.
Likewise, returning another instance of the builder than defaultBuilder's might result in loss of functionality if not reimplemented.int
getPushNotificationId
(Context context, int defaultId, Bundle pushIntentExtras) Notification Id to use when posting the notification to the system.
-
Constructor Details
-
BatchNotificationInterceptor
public BatchNotificationInterceptor()
-
-
Method Details
-
getPushNotificationCompatBuilder
public androidx.core.app.NotificationCompat.Builder getPushNotificationCompatBuilder(Context context, androidx.core.app.NotificationCompat.Builder defaultBuilder, Bundle pushIntentExtras, int notificationId) Get the builder instance used to generate the notification.
If you're basing your builder on defaultBuilder, some methods might have undefined behaviour as Batch already calls many of them.
Likewise, returning another instance of the builder than defaultBuilder's might result in loss of functionality if not reimplemented.- Parameters:
context
- Context. Will usually be a service context.defaultBuilder
- NotificationCompat builder that has been created and fully configured by Batch.pushIntentExtras
- Raw push intent extras. Read directly your custom payload values from the extras as string values, or useBatchPushPayload#payloadFromReceiverExtras(Bundle)
to extract Batch data from the extras.notificationId
- Notification id that will be used to post the notification. Result ofgetPushNotificationId(android.content.Context,int,android.os.Bundle)
.- Returns:
- A valid
NotificationCompat.Builder
instance, or null if you want to stop the display of that notification.
-
getPushNotificationId
Notification Id to use when posting the notification to the system. This id should be unique per notification, unless you want to update it with other pushes (such as a sports game score update, for example) If you always return the same value, the notification can behave unexpectedly.- Parameters:
context
- Context. Will usually be a service context.defaultId
- Notification Id that was generated and about to be used by BatchpushIntentExtras
- Raw push intent extras. Read directly your custom payload values from the extras as string values, or useBatchPushPayload#payloadFromReceiverExtras(Bundle)
to extract Batch data from the intent.- Returns:
- A valid notification id.
-