Skip to content

Bug: subscriptionCallback not called during push notification re-registration after FCM key mismatch #480

@jagdish-gh

Description

@jagdish-gh

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

  1. Set up a web push subscription with one FCM provider/key
  2. Change the FCM key to a different value in CleverTap configuration
  3. Trigger push notification registration
  4. Observe the error message in console
  5. Notice that the SDK unsubscribes and re-registers successfully
  6. Verify that the subscriptionCallback function 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions