fix: create unsubscribed subscription for opted-out user when migrating#1430
Open
sherwinski wants to merge 5 commits intomainfrom
Open
fix: create unsubscribed subscription for opted-out user when migrating#1430sherwinski wants to merge 5 commits intomainfrom
sherwinski wants to merge 5 commits intomainfrom
Conversation
Previously, the SDK would skip creating any subscription on app ID2 when migrating from app ID1 if the subscription was opted-out at the time of migration. Now, the SDK will create a new Subscription with the status "Not Subscribed" on app ID2. This could be achieved by creating a "Subscribed" subscription and then immediately updating it to "Opted Out", which requires two server operations. This commit updates the logic to thread a `notificationTypesOverride` parameter through `registerForPush` → `_subscribe` → `updatePushSubscriptionModelWithRawSubscription` so the `CreateSubscriptionOperation` is sent with notification_types = -2 (UserOptedOut) from the start. This results in a single server operation and avoids any transient intermediary states.
299715f to
d6f420c
Compare
Update `createOptedOutSubscriptionForMigration` to call `_subscribe()` directly instead of `registerForPush()`. This creates the model with `_UserOptedOut` and calls `createUserOnServer()` to send the `CreateSubscriptionOperation` with the correct state, without triggering the `_registerSubscription` and `checkAndTriggerSubscriptionChanged` steps that fight against the opted-out state.
sherwinski
commented
Feb 27, 2026
Comment on lines
+419
to
+422
| await OneSignal._context._subscriptionManager._subscribe( | ||
| SubscriptionStrategyKind._ResubscribeExisting, | ||
| NotificationType._UserOptedOut, | ||
| ); |
Contributor
Author
There was a problem hiding this comment.
Open to suggestions if there's a better way to achieve this.
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
Create a new Subscription with the status "Not Subscribed" when migrating an opted-out user between one app ID and another.
Details
Previously, the SDK would skip creating any subscription on app ID2 when migrating from app ID1 if the subscription was opted-out at the time of migration. Now, the SDK will create a new Subscription with the status "Not Subscribed" on app ID2.
This could be achieved by creating a "Subscribed" subscription and then immediately updating it to "Opted Out", which requires two server operations. Instead, this PR updates the logic to thread a
notificationTypesOverrideparameter throughregisterForPush→_subscribe→updatePushSubscriptionModelWithRawSubscriptionso thatCreateSubscriptionOperationis sent with notification_types = -2 (UserOptedOut) from the start.This results in a single server operation and avoids any transient intermediary states.
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