PushFeature

Package: com.salesforce.marketingcloud.pushfeature

Type: class

Implements: ModuleInterface

Description 

Main class for the Push Feature Module.

This class provides comprehensive functionality for push notifications and related features within the Salesforce Marketing Cloud SDK.

Key Features:

  • Firebase Cloud Messaging (FCM) integration
  • Push token management and refresh
  • Push notification enablement/disablement
  • Silent push message handling
  • Job scheduling for background operations
  • State management and debugging capabilities

Initialization Pattern:

  • Singleton pattern with thread-safe initialization
  • State management and lifecycle handling
  • Component-based architecture
  • Proper error handling and logging
  • Asynchronous initialization with completion callbacks

Thread Safety: This class is thread-safe and uses atomic operations for state management. All public methods can be called from any thread.

Since: 1.0.0

Example Usage 

1// Initialize PushFeature module
2PushFeature.init(context, config, sdkComponents) { status ->
3    if (status.isUsable) {
4        val pushFeature = PushFeature.getInstance()
5        val pushMessageManager = pushFeature.getPushMessageManager()
6        // Register for token refresh events
7        pushMessageManager.registerTokenRefreshListener { token ->
8            // Handle new token
9        }
10    }
11}

Types 

Companion 

object Companion

Properties 

state 

1open override val state: JSONObject

Returns the current state of the PushFeature module as a JSONObject.

Methods 

getConfig 

1fun getConfig(): PushFeatureConfig

Gets the configuration used to initialize this PushFeature instance.

Returns: The PushFeatureConfig instance


getInitializationStatus 

1fun getInitializationStatus(): PushFeatureInitializationStatus?

Gets the initialization status of this PushFeature instance.

Returns: The initialization status or null if not initialized


getNotificationManager 

1fun getNotificationManager(): NotificationManager

Gets the NotificationManager instance for notification operations.

Returns: The NotificationManager instance


getPushMessageManager 

1fun getPushMessageManager(): PushMessageManager

Gets the PushMessageManager instance for push notification operations.

Returns: The PushMessageManager instance


isTornDown 

1fun isTornDown(): Boolean

Checks if the PushFeature instance is torn down.

Returns: true if torn down, false otherwise