Fix legacy player ID was not cached properly when upgrading from v3 #1345
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
One Line Summary
Correctly cache push subscription ID when upgrading from v3 for use in receive receipts and notification opened requests.
Details
Correctly cache push subscription ID when upgrading from v3
We were not saving the
OSUD_PUSH_SUBSCRIPTION_ID
to user defaults when we detected a legacy player ID and proceed with upgrading.It was only saved from create user responses that hydrate the subscription model, which does not happen on v3 -> v5 upgrade.
Receive receipts and notification opened requests use this value from the cache.
Save push subscription ID on app start
Because of the bug that this PR aims to fix, players that upgraded from v3 -> v5 were missing the player ID in cache for sending to notification opened and notification received endpoints.
Now, to remedy, every time app cold starts, as part of the push subscription model checking itself for updates, we will cache its subscription ID if non-empty.
Future Work
Consider some sort of migration in Core that the extension and user manager can utilize.
Also, this will not fix the issue for users that updated their app and did not open it yet.
Motivation
It was brought up by other team members that many receive receipts and notification opened requests are missing the player ID.
Scope
Sending non-null player ID to receive receipts and notification opened endpoints.
Testing
Unit testing
None, should consider adding
Manual testing
iPhone 13 on iOS 17.1
Scenario 1 Tested mimics v3 -> v5 -> this PR
a. see player created in dashboard
main
which is v5.0.4, prior to this PRa. see legacy player get migrated in SDK
b. player in dashboard remains the same but with sdk version updated to 5.0.4
c. Receive receipts and notification opened will be missing player ID
a. Now receive receipts and notification opened will have player ID
Scenario 2 Tested mimics v3 -> this PR
Scenario 3 Tested using new app install
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)