Class BatchNotificationInterceptor

java.lang.Object
com.batch.android.BatchNotificationInterceptor

public abstract class BatchNotificationInterceptor extends Object
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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    int
    getPushNotificationId(Context context, int defaultId, Bundle pushIntentExtras)
    Notification Id to use when posting the notification to the system.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 use BatchPushPayload#payloadFromReceiverExtras(Bundle) to extract Batch data from the extras.
      notificationId - Notification id that will be used to post the notification. Result of getPushNotificationId(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

      public int getPushNotificationId(Context context, int defaultId, Bundle pushIntentExtras)
      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 Batch
      pushIntentExtras - Raw push intent extras. Read directly your custom payload values from the extras as string values, or use BatchPushPayload#payloadFromReceiverExtras(Bundle) to extract Batch data from the intent.
      Returns:
      A valid notification id.