Marketing Cloud SDK / com.salesforce.marketingcloud.notifications / NotificationManager

NotificationManager

abstract class NotificationManager

Types

NotificationBuilder

Provide your NotificationBuilder in the NotificationCustomizationOptions when initializing the SDK via com.salesforce.marketingcloud.MarketingCloudConfig.Builder#setNotificationCustomizationOptions(NotificationCustomizationOptions). If the builder is provided it is expected to be complete and will be used as-is by the SDK to display the notification. Please consult the Android documentation to ensure completeness.

interface NotificationBuilder

NotificationChannelIdProvider

Provide your NotificationChannelIdProvider in the NotificationCustomizationOptions when initializing the SDK via com.salesforce.marketingcloud.MarketingCloudConfig.Builder#setNotificationCustomizationOptions(NotificationCustomizationOptions).

interface NotificationChannelIdProvider

NotificationLaunchIntentProvider

Provide your NotificationLaunchIntentProvider in the NotificationCustomizationOptions when initializing the SDK via com.salesforce.marketingcloud.MarketingCloudConfig.Builder#setNotificationCustomizationOptions(NotificationCustomizationOptions).

interface NotificationLaunchIntentProvider

NotificationMessageDisplayedListener

interface NotificationMessageDisplayedListener

ShouldShowNotificationListener

interface ShouldShowNotificationListener

Constructors

<init>

NotificationManager()

Properties

DEFAULT_CHANNEL_ID

The channel id of the default notification channel created be the SDK.

static val DEFAULT_CHANNEL_ID: String

Functions

areNotificationsEnabled

Returns whether or not notifications are enabled. If false then the user will not see any notifications. (Push, Geofence, or Beacon).

abstract fun areNotificationsEnabled(): Boolean

cancelNotificationMessage

Will cancel the notification associated with the provided message.

open static fun cancelNotificationMessage(context: Context, message: NotificationMessage): Unit

createDefaultNotificationChannel

Will create the default notification channel used by the SDK.

open static fun createDefaultNotificationChannel(context: Context, forceRecreate: Boolean): String

Will create the default notification channel used by the SDK only if it does not already exist.

open static fun createDefaultNotificationChannel(context: Context): String

disableNotifications

Disables notifications in the SDK. This does not disable any individual message type(Push, Geofence, or Beacon), but will simply prevent the notification from being shown on the device.Consider only using this for short term disablement of notifications. If you're desire it to turn notifications off long-term then consider disabling each message type directly as that will prevent the device from receiving those messages in the first place.

abstract fun disableNotifications(): Unit

enableNotifications

Enables notifications in the SDK. This does not enable any individual message type(Push, Geofence, or Beacon), but will simply allow notifications to be shown on the device.Notifications are enabled by default.

abstract fun enableNotifications(): Unit

extractMessage

Extracts the NotificationMessage from the Intent.

open static fun extractMessage(intent: Intent): NotificationMessage?

getDefaultNotificationBuilder

This method will build out a androidx.core.app.NotificationCompat.Builder with the defaults typically used by the SDK. It will set the following:

  • title text
  • alert text
  • small icon
  • large icon
  • big image
  • sound (*Only works on devices prior to Android O*)

open static fun getDefaultNotificationBuilder(context: Context, message: NotificationMessage, channelId: String, smallIconResId: Int): Builder

redirectIntentForAnalytics

Returns a PendingIntent that will redirect to our internal Service to handle notification opened analytics. Once the analytic has been logged it will redirect the application to the provided .

open static fun redirectIntentForAnalytics(context: Context, openIntent: PendingIntent, message: NotificationMessage, autoCancel: Boolean): PendingIntent

registerNotificationMessageDisplayedListener

Registers the provided listener.

abstract fun registerNotificationMessageDisplayedListener(listener: NotificationMessageDisplayedListener): Unit

setShouldShowNotificationListener

Set a Should Show Notification Listener that will be queried as to whether or not a given notification should be displayed by the SDK. Setting the listener to null effectively clears the value within the SDK and returns message handling to its default behavior.

abstract fun setShouldShowNotificationListener(listener: ShouldShowNotificationListener?): Unit

unregisterNotificationMessageDisplayedListener

Unregisters the provided listener.

abstract fun unregisterNotificationMessageDisplayedListener(listener: NotificationMessageDisplayedListener): Unit