PushFeatureConfig
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
com.salesforce.marketingcloud.pushfeature.config
A data class that extends PushFeatureModuleConfig to configure push notification functionality for the Salesforce Marketing Cloud SDK. It provides settings for Firebase Cloud Messaging integration, notification customization, URL handling, and notification filtering.
1data class PushFeatureConfig : PushFeatureModuleConfigPushFeatureModuleConfig1@JvmField
2val senderId: String?The Firebase Cloud Messaging sender ID for push notifications. This is required for FCM integration.
1@JvmField
2val notificationCustomizationOptions: NotificationCustomizationOptionsConfiguration options for customizing notification appearance and behavior, including icon, sound, LED color, and other visual elements.
1@JvmField
2val urlHandler: UrlHandler?Optional handler for processing URLs from push notifications. Implement this interface to customize URL handling behavior.
1@JvmField
2val shouldShowNotificationListener: NotificationManager.ShouldShowNotificationListener?Optional listener for filtering or controlling whether notifications should be displayed. Allows dynamic control of notification visibility based on custom logic.
1fun toBuilder(): PushFeatureConfig.BuilderCreates a new Builder instance initialized with the current configuration values.
Returns: A Builder with current configuration values
1class PushFeatureConfig.BuilderBuilder class for constructing PushFeatureConfig instances using a fluent API pattern.
1fun setSenderId(senderId: String?): BuilderSets the Firebase Cloud Messaging sender ID.
Parameters:
senderId - The FCM sender ID (typically a 12-digit number)Returns: The Builder instance for method chaining
1fun setNotificationCustomizationOptions(options: NotificationCustomizationOptions): BuilderSets the notification customization options.
Parameters:
options - NotificationCustomizationOptions instance with customization settingsReturns: The Builder instance for method chaining
1fun setUrlHandler(handler: UrlHandler?): BuilderSets the URL handler for processing notification URLs.
Parameters:
handler - UrlHandler implementation or nullReturns: The Builder instance for method chaining
1fun setShouldShowNotificationListener(listener: NotificationManager.ShouldShowNotificationListener?): BuilderSets the listener for controlling notification visibility.
Parameters:
listener - ShouldShowNotificationListener implementation or nullReturns: The Builder instance for method chaining
1fun build(): PushFeatureConfigFinalizes the configuration and creates the PushFeatureConfig instance.
Returns: A new PushFeatureConfig instance with the specified configuration
1object CompanionCompanion object providing factory methods for creating Builder instances.
1fun builder(): PushFeatureConfig.BuilderCreates a new Builder instance for constructing a PushFeatureConfig.
Returns: A new PushFeatureConfig.Builder instance
1val pushConfig = PushFeatureConfig.builder()
2 .setSenderId("123456789012")
3 .setNotificationCustomizationOptions(
4 NotificationCustomizationOptions.create(R.drawable.ic_notification)
5 )
6 .setUrlHandler(customUrlHandler)
7 .setShouldShowNotificationListener { message ->
8 // Return true to show notification, false to suppress
9 true
10 }
11 .build()