Class BatchNotificationInterceptor


  • public abstract class BatchNotificationInterceptor
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      androidx.core.app.NotificationCompat.Builder getPushNotificationCompatBuilder​(android.content.Context context, androidx.core.app.NotificationCompat.Builder defaultBuilder, android.os.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​(android.content.Context context, int defaultId, android.os.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 Detail

      • BatchNotificationInterceptor

        public BatchNotificationInterceptor()
    • Method Detail

      • getPushNotificationCompatBuilder

        @Nullable
        public androidx.core.app.NotificationCompat.Builder getPushNotificationCompatBuilder​(@NonNull
                                                                                             android.content.Context context,
                                                                                             @NonNull
                                                                                             androidx.core.app.NotificationCompat.Builder defaultBuilder,
                                                                                             @NonNull
                                                                                             android.os.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(Context, int, Bundle).
        Returns:
        A valid NotificationCompat.Builder instance, or null if you want to stop the display of that notification.
      • getPushNotificationId

        public int getPushNotificationId​(@NonNull
                                         android.content.Context context,
                                         int defaultId,
                                         @NonNull
                                         android.os.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.