-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Bug Description
When a push subscription already exists with a different FCM provider, CleverTap subscription fails with the error:
CleverTap [1759204088486]: Error subscribing: InvalidStateError: Registration failed - A subscription with a different applicationServerKey (or gcm_sender_id) already exists; to change the applicationServerKey, unsubscribe then resubscribe.
The SDK correctly unsubscribes and retries the subscription, but the subscriptionCallback function is not being called during the re-registration process.
Steps to Reproduce
- Set up a web push subscription with one FCM provider/key
- Change the FCM key to a different value in CleverTap configuration
- Trigger push notification registration
- Observe the error message in console
- Notice that the SDK unsubscribes and re-registers successfully
- Verify that the
subscriptionCallbackfunction is not called after successful re-registration
Expected Behavior
After successful re-registration following unsubscription due to FCM key mismatch, the subscriptionCallback function should be called.
Actual Behavior
The subscriptionCallback function is not called during the re-registration process, even though the subscription is successful.
Code Location
File: src/modules/notification.js
Line: 328
Method: #setUpChromeFirefoxNotifications error handling flow
Environment
- SDK Version: 2.3.0
- Browsers: Chrome, Firefox, Safari
- Platform: Web
Impact
This affects applications that need to perform post-subscription actions (like UI updates, analytics tracking, etc.) when the subscription is re-established after an FCM key change.
Additional Context
The issue occurs in the error handling flow where the SDK calls:
window.clevertap.notifications.push({
skipDialog: true
// subscriptionCallback is missing here
})The subscriptionCallback parameter should be included in this call to ensure the callback is executed after successful re-registration.