java.lang.Object | |
↳ | com.salesforce.marketingcloud.notifications.NotificationManager |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | NotificationManager.NotificationBuilder | Provide your NotificationManager.NotificationBuilder in the NotificationCustomizationOptions when
initializing the SDK via setNotificationCustomizationOptions(NotificationCustomizationOptions) . |
|||||||||
interface | NotificationManager.NotificationChannelIdProvider | Provide your NotificationManager.NotificationChannelIdProvider in the NotificationCustomizationOptions when
initializing the SDK via setNotificationCustomizationOptions(NotificationCustomizationOptions) . |
|||||||||
interface | NotificationManager.NotificationLaunchIntentProvider | Provide your NotificationManager.NotificationLaunchIntentProvider in the NotificationCustomizationOptions when
initializing the SDK via setNotificationCustomizationOptions(NotificationCustomizationOptions) . |
|||||||||
interface | NotificationManager.NotificationMessageDisplayedListener | ||||||||||
interface | NotificationManager.ShouldShowNotificationListener |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_CHANNEL_ID | The channel id of the default notification channel created be the SDK. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NotificationManager() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract boolean |
areNotificationsEnabled()
Returns whether or not notifications are enabled.
| ||||||||||
static void |
cancelNotificationMessage(Context context, NotificationMessage message)
Will cancel the notification associated with the provided
message . | ||||||||||
static String |
createDefaultNotificationChannel(Context context)
Will create the default notification channel used by the SDK only if it does not already exist.
| ||||||||||
static String |
createDefaultNotificationChannel(Context context, boolean forceRecreate)
Will create the default notification channel used by the SDK.
| ||||||||||
abstract void |
disableNotifications()
Disables notifications in the SDK.
| ||||||||||
abstract void |
enableNotifications()
Enables notifications in the SDK.
| ||||||||||
static NotificationMessage |
extractMessage(Intent intent)
Extracts the
NotificationMessage from the Intent. | ||||||||||
static NotificationCompat.Builder |
getDefaultNotificationBuilder(Context context, NotificationMessage message, String channelId, int smallIconResId)
This method will build out a android.support.v4.app.NotificationCompat.Builder with
the defaults typically used by the SDK.
| ||||||||||
static PendingIntent |
redirectIntentForAnalytics(Context context, PendingIntent openIntent, NotificationMessage message, boolean autoCancel)
Returns a PendingIntent that will redirect to our internal Service to handle notification opened
analytics.
| ||||||||||
abstract void |
registerNotificationMessageDisplayedListener(NotificationManager.NotificationMessageDisplayedListener listener)
Registers the provided
listener . | ||||||||||
abstract void |
setShouldShowNotificationListener(NotificationManager.ShouldShowNotificationListener listener)
Set a
Should Show Notification Listener that will be queried as
to whether or not a given notification should be displayed by the SDK. | ||||||||||
abstract void |
unregisterNotificationMessageDisplayedListener(NotificationManager.NotificationMessageDisplayedListener listener)
Unregisters the provided
listener . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
The channel id of the default notification channel created be the SDK.
Returns whether or not notifications are enabled.
If false
then the user will not see any notifications. (Push, Geofence, or Beacon).
Will cancel the notification associated with the provided message
.
Will create the default notification channel used by the SDK only if it does not already exist.
context | Context |
---|
Will create the default notification channel used by the SDK.
context | Context |
---|---|
forceRecreate | It true, the SDK will create the channel even if it already exists.
If you have provided localization for the SDK's channel name
R.string.mcsdk_default_notification_channel_name then you will need to
pass true when the user changes the language on their device. |
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.
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.
Extracts the NotificationMessage
from the Intent.
intent | android.content.Intent used to launch Android component from a push open. |
---|
This method will build out a android.support.v4.app.NotificationCompat.Builder with the defaults typically used by the SDK. It will set the following:
You will need to set the android.support.v4.app.NotificationCompat.Builder#setContentIntent(PendingIntent)
and wrap the PendingIntent using redirectIntentForAnalytics(Context, PendingIntent, NotificationMessage, boolean)
to receive open analytics when the notification is clicked.
context | The context provided by the SDK. |
---|---|
message | The message provided by the SDK. |
channelId | The notification channel ID. If this channel does not exist then your notification will not be displayed on devices running Android O (Oreo) or newer. |
smallIconResId | The resource id for the small icon to be used in the notification. |
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 PendingIntent openIntent.
context | The context to use to create the android.app.PendingIntent |
---|---|
openIntent | PendingIntent to be used when the notification is clicked. |
message | Message associated with the notification |
autoCancel | If true, the notification will be clear from the notification shade once it has been clicked |
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.
listener | an instance of the interface |
---|