PushMessageManager

Package: com.salesforce.marketingcloud.pushfeature.push

Module: Push Feature Module v2.0.0

Overview 

1abstract class PushMessageManager

Abstract class for managing push messages in the PushFeature module. Provides APIs for token management, message handling, and push enablement.

This class serves as the public interface for push functionality, similar to the original PushMessageManager in the main SDK.

Constructors 

PushMessageManager 

1constructor()

Nested Types 

Companion 

1object Companion

PushStatus 

1sealed interface PushStatus

Represents the current state of push enablement, providing detailed information about why push notifications might be disabled.

PushTokenRefreshListener 

1fun interface PushTokenRefreshListener

Listener interface for push token refresh events.

SilentPushListener 

1fun interface SilentPushListener

Listener interface for silent push messages. Silent push messages are background messages that don’t display notifications.

Methods 

enablePush 

1abstract fun enablePush()

Enables push messaging in the SDK. Push messaging is on by default. If after enabling push you still don’t see notifications then check the system notification settings.

disablePush 

1abstract fun disablePush()

Disables push messaging in the SDK. Calling this will result in no push messages being sent to the device.

isPushEnabled 

1abstract fun isPushEnabled(): Boolean

Returns whether or not push messaging is enabled. If false then no push messages will be sent to the device.

Returns: Boolean - True if push messaging is enabled

getPushEnabledState 

1abstract fun getPushEnabledState(): PushMessageManager.PushStatus

Returns the current state of push messaging enablement with detailed information about why push notifications might be disabled.

Returns: PushMessageManager.PushStatus - Current push status

getPushToken 

1abstract fun getPushToken(): String?

Returns the push token used to push. This is either the value retrieved by the SDK or the one provided in setPushToken.

Returns: String? - The push token, or null if not available

setPushToken 

1abstract fun setPushToken(pushToken: String)

Only call this method if you are handling the request, and refresh of, the push token from Google. Set the push token to be used by the Marketing Cloud to send push messages to the device. The push token is a required value to send a registration payload to the Marketing Cloud so if you fail to set this value you will not see updates to the registration.

Parameters:

  • pushToken: String - The push token from Google

handleMessage (RemoteMessage) 

1abstract fun handleMessage(message: RemoteMessage): Boolean

Handles the remote message payload for any message sent from the Marketing Cloud.

Parameters:

  • message: RemoteMessage - The remote message to handle

Returns: Boolean - True if the message was handled

handleMessage (Map) 

1abstract fun handleMessage(pushData: Map<String, String>): Boolean

Handles the push message payload for any message sent from the Marketing Cloud.

Parameters:

  • pushData: Map<String, String> - The push message data

Returns: Boolean - True if the message was handled

getPushDebugInfo 

1abstract fun getPushDebugInfo(): JSONObject

Returns information that can help investigate push message issues. Please be sure to provide this information when submitting a request for support.

Returns: JSONObject - Debug information as JSON

registerTokenRefreshListener 

1abstract fun registerTokenRefreshListener(listener: PushMessageManager.PushTokenRefreshListener)

Registers the provided PushTokenRefreshListener.

Parameters:

  • listener: PushMessageManager.PushTokenRefreshListener - The listener to register

unregisterTokenRefreshListener 

1abstract fun unregisterTokenRefreshListener(listener: PushMessageManager.PushTokenRefreshListener)

Unregisters the provided PushTokenRefreshListener.

Parameters:

  • listener: PushMessageManager.PushTokenRefreshListener - The listener to unregister

registerSilentPushListener 

1abstract fun registerSilentPushListener(listener: PushMessageManager.SilentPushListener)

Registers the provided SilentPushListener.

Parameters:

  • listener: PushMessageManager.SilentPushListener - The listener to register

unregisterSilentPushListener 

1abstract fun unregisterSilentPushListener(listener: PushMessageManager.SilentPushListener)

Unregisters the provided SilentPushListener.

Parameters:

  • listener: PushMessageManager.SilentPushListener - The listener to unregister