Using Multiple Push Providers
The SDK supports multiple push providers simultaneously.
- Android
- Kotlin Multiplatform
- iOS
- Web
Register additional Firebase Cloud Messaging (FCM) or Huawei Mobile Services (HMS) services using the registerMessagingService() method.
fun registerMessagingService(
messagingService: FirebaseMessagingService / HmsMessageService,
registrationOptions: FirebaseMessagingServiceRegistrationOptions / HuaweiMessagingServiceRegistrationOptions
)
messagingServiceis the service you want to register.registrationOptionsis a data class for configuring the registration. It has a single property that either includes or excludes notifications from SAP Engagement.
FirebaseMessagingServiceRegistrationOptions(
val includeEngagementCloudMessages: Boolean = false
)
Kotlin Multiplatform apps run on multiple platforms. The push provider registration depends on the platform the app is running on. Refer to the Android and iOS tabs for the platform-specific provider registration options.
You can register multiple UNUserNotificationCenterDelegate implementations with the SDK using the registerNotificationCenterDelegate method:
// Register a delegate with default options (won't receive EC notifications)
EngagementCloud.shared.push.registerNotificationCenterDelegate(delegate: myDelegate)
// Register a delegate to also receive Engagement Cloud notifications
let options = NotificationCenterDelegateRegistrationOptions(includeEngagementCloudMessages: true)
EngagementCloud.shared.push.registerNotificationCenterDelegate(delegate: myOtherDelegate, options: options)
Configuration Options:
NotificationCenterDelegateRegistrationOptions(
includeEngagementCloudMessages: Bool = false
)
includeEngagementCloudMessages- Whentrue, the delegate receives all notifications, including messages from SAP Engagement Cloud. Default isfalse, meaning the delegate receives all notifications except messages from SAP Engagement Cloud.
unregisterNotificationCenterDelegate
Removes a previously registered delegate.
EngagementCloud.shared.push.unregisterNotificationCenterDelegate(delegate: myDelegate)
registeredNotificationCenterDelegates
Returns the list of currently registered delegates with their active configuration.
let delegates = EngagementCloud.shared.push.registeredNotificationCenterDelegates
// Returns: [NotificationCenterDelegateRegistration]
NotificationCenterDelegateRegistrationOptions
| Property | Type | Default | Description |
|---|---|---|---|
includeEngagementCloudMessages | Bool | false | When true, the delegate receives all notifications, including messages from SAP Engagement Cloud. When false, the delegate receives all notifications except messages from SAP Engagement Cloud. |
For more information, refer to the integration documentation.
You can register additional service workers alongside the ems-service-worker to receive and handle notifications.
Strategy for Using Multiple Providers
- Android
- Kotlin Multiplatform
- iOS
- Web
When supporting both FCM and HMS:
- Detect the device ecosystem (GMS or HMS) at runtime. Register the relevant messaging service first.
- Avoid registering both message services as they can lead to redundant tokens and message duplication.
- Use the
includeEngagementCloudMessagesflag consistently across services.
Kotlin Multiplatform apps run on multiple platforms. When using multiple push providers, the strategy depends on the platform the app is running on. Refer to the Android and iOS tabs for platform-specific guidance.
iOS Delegate Registration
When combining Engagement Cloud delegate with custom logic:
- Register your custom delegate using
registerNotificationCenterDelegate(delegate:options:). - Use
includeEngagementCloudMessages: trueif your delegate needs to process EC notifications. - Keep Engagement Cloud delegate (
userNotificationCenterDelegate) as the main delegate onUNUserNotificationCenterto ensure attribution & tracking occurs.
// Example: Register a custom delegate that handles all notifications
let options = NotificationCenterDelegateRegistrationOptions(includeEngagementCloudMessages: true)
EngagementCloud.shared.push.registerNotificationCenterDelegate(delegate: myAnalyticsDelegate, options: options)
// The SDK delegate should remain as the center's delegate
UNUserNotificationCenter.current().delegate = EngagementCloud.shared.push.userNotificationCenterDelegate
Limit your worker count. Each additional service worker increases maintenance complexity. Prefer one central worker that handles branching logic.