Package 

Class Batch.Messaging

    • Method Detail

      • setShowForegroundLandings

         static void setShowForegroundLandings(boolean showForegroundLandings)

        Toggle whether mobile landings should be shown directly rather than displaying a notificationwhen the app is in foreground.

        Default is false.

        Parameters:
        showForegroundLandings - True to enable show landings, false to display a notification like when the application is in the background.
      • setAutomaticMode

         static void setAutomaticMode(boolean automatic)

        Toggle this module's automatic mode. By default, this value is "true".

        If you disable automatic mode, you will have to implement loadFragment

        Parameters:
        automatic - True to enable the automatic mode, false to disable it.
      • setTypefaceOverride

         static void setTypefaceOverride(@Nullable() Typeface normalTypeface, @Nullable() Typeface boldTypeface)

        Override the Typeface (aka font) used by Batch's messaging views.You'll need to provide both the normal and bold typefaces. If you only provide one, the result might be inconsistent.

        In order to revert to the system font, set the typefaces to null.

        Parameters:
        normalTypeface - Typeface for normal text.
        boldTypeface - Typeface for bold text.
      • loadFragment

        @NonNull() static DialogFragment loadFragment(@NonNull() Context context, @NonNull() BatchMessage message)

        Load the Fragment corresponding to the message payload.This method should be called from your UI thread.

        If the specified message contains a banner, this method will throw a BatchMessagingException.You should then fallback on loadBanner, or attempt it before,as there is currently no way of checking whether a BatchMessage contains a banner, an interstitial,or any potential future format.

        Parameters:
        context - Your activity's context.
        message - Message to display.
      • show

         static void show(@NonNull() Context context, @NonNull() BatchMessage message)

        Asynchronously show the BatchMessage. It will be displayed in a dedicated activity (MessagingActivity).

        Note that if this method will work even if Batch is in do not disturb mode.

        The given context should be an Activity instance to enable support for the banner format, as ithas to be attached to an activity. If you want to tweak how the SDK displays a banner, you can implement Batch.Messaging.DisplayHintProvider in your activity.

        Parameters:
        context - Your activity's context, Can't be null.
        message - Message to show.
      • setDoNotDisturbEnabled

         static void setDoNotDisturbEnabled(boolean enableDnd)

        Toggles whether Batch.Messaging should entier its "do not disturb" (DnD) mode, or exit it.

        While in DnD, Batch will not display landings, not matter if they've been triggered by notifications or an In-App Campaign, even in automatic mode.

        This mode is useful for times where you don't want Batch to interrupt your user, such as during a splashscreen, a video or an interstitial ad.

        If a message should have been displayed during DnD, Batch will enqueue it, overwriting any previously enqueued message.When exiting DnD, Batch will not display the message automatically: you'll have to call the queue management methods to display the message, if you want to.See hasPendingMessage, popPendingMessage to manage the enqueued message, if any.

        Note: This is only supported if automatic mode is disabled. Messages will not be enqueued, as they will be delivered to your LifecycleListener2 implementation.

        Parameters:
        enableDnd - true to enable DnD, false to disable it
      • isDoNotDisturbEnabled

         static boolean isDoNotDisturbEnabled()

        Check if Batch Messaging is currently in Do Not Disturb mode

      • hasPendingMessage

         static boolean hasPendingMessage()

        Check if Batch currently has a pending message, without forgetting it.

      • popPendingMessage

        @Nullable() static BatchMessage popPendingMessage()

        Gets the currently enqueued message.

        Note: Calling this removes the pending message from Batch's queue. Further calls to thismethod will return null, until another message gets enqueues.