-
Notifications
You must be signed in to change notification settings - Fork 19
fix: ensure subscriptionCallback is passed during push notification r… #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: ensure subscriptionCallback is passed during push notification r… #481
Conversation
…e-registration When a different FCM key exists and push subscription fails, the SDK unregisters and registers again. However, during the re-registration process, the subscriptionCallback function was not being passed to the notifications.push() call, causing the callback to not be executed. This fix ensures that the subscriptionCallback parameter is included when calling notifications.push() during the unsubscription error handling flow, allowing the callback to be properly executed after successful re-registration. Fixes issue where subscriptionCallback was not called after FCM key change and subsequent push notification re-registration.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
WalkthroughThe code now passes an additional Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)src/modules/notification.js (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Changes
Fixed a bug in the CleverTap Web SDK notification service where the
subscriptionCallbackfunction was not being called during push notification re-registration when a different FCM key exists.Jira Issue Reference: [Add your Jira issue reference here]
Root Cause
When a different FCM key exists than the current push subscription, the subscription fails and the SDK unregisters and registers again. However, during this re-registration process in the error handling flow, the
subscriptionCallbackparameter was not being passed to thenotifications.push()call, causing the callback function to not be executed after successful re-registration.Changes Made
src/modules/notification.jssubscriptionCallback: subscriptionCallbackparameter to thewindow.clevertap.notifications.push()call in the unsubscription error handling flowChanges to Public Facing API if any
No changes to the public facing API. This is a bug fix that ensures existing functionality works as expected.
How Has This Been Tested?
Testing Approach:
FCM Key Mismatch Scenario:
subscriptionCallbackfunction is called after successful re-registrationRegression Testing:
Test Configuration:
Checklist
Link to Deployed SDK
Use these URLs for testing:
https://static.wizrocket.com/staging/fix/notification-subscription-callback-missing-on-reregister/js/clevertap.min.jshttps://static.wizrocket.com/staging/fix/notification-subscription-callback-missing-on-reregister/js/sw_webpush.min.jsHow to trigger Automations
Just add an empty commit after all your changes are done in the PR with the command:
git commit --allow-empty -m "[run-test] Testing Automation"This will trigger the automation suite.
Summary by CodeRabbit