fix: clear stale persisted state when App ID changes during migration#1424
Merged
sherwinski merged 9 commits intomainfrom Feb 27, 2026
Merged
fix: clear stale persisted state when App ID changes during migration#1424sherwinski merged 9 commits intomainfrom
sherwinski merged 9 commits intomainfrom
Conversation
e5a244b to
bfa762e
Compare
fadi-george
reviewed
Feb 25, 2026
fadi-george
reviewed
Feb 26, 2026
Contributor
|
If i keep opted in it seems to work fine for migrate. |
Contributor
|
Error seemed to happen here: |
Contributor
Author
Good catch. 5c593b3 makes it so that no error is thrown and no subscription is created on the second app. |
Contributor
|
Rebase |
fadi-george
approved these changes
Feb 26, 2026
When migrating App IDs on the same origin, IndexedDB retains subscription models, push tokens, and lastKnown values from the previous App ID. This causes the SDK to attempt updating a subscription ID that doesn't exist under the new App ID, and prevents `checkAndTriggerSubscriptionChanged()` from detecting a state change, leaving the subscription stuck as "unsubscribed". This commit detects the App ID change in `initSaveState()` and clears all stale persisted state so the auto-resubscribe flow creates a fresh subscription with `notification_types = Subscribed`.
When the subscription was opted out during migration, clearing the model store without also clearing `deviceId` causes `isAlreadyRegisteredWithOneSignal()` to return true. This caused session management to call `getOneSignalAndSubscriptionIds()` with no subscription model, throwing a "No subscription" error. Clearing `userId` alongside the other stale Ids ensures the SDK doesn't enter existing-user session paths when no subscription model exists.
9185076 to
5ba1d63
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
1 Line Summary
Provides the
handleAutoResubscribe()flow with clean state so that stale subscription data does not get used during migration.Details
When migrating App IDs on the same origin, IndexedDB retains subscription models, push tokens, and lastKnown values from the previous App ID. This causes the SDK to attempt updating a subscription ID that doesn't exist under the new App ID, and prevents
checkAndTriggerSubscriptionChanged()from detecting a state change, leaving the subscription stuck as "unsubscribed".This PR detects the App ID change in
initSaveState()and clears all stale persisted state so the auto-resubscribe flow creates a fresh subscription withnotification_types = Subscribed.Systems Affected
Validation
Tests
Info
Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemapcontextif possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.contextScreenshots
Info
Checklist
Related Tickets
This change is