Migration: Missing onesignalId during initWithContext #2009
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
Add default subscription status if legacy user info was previously saved on the device.
Details
Motivation
We've received crash reports from this thread #1995, indicating a crash caused by a null pointer exception when calling onesignal_id during the initWithText process. After some research, I discovered that this only occurs when the push subscription status is missing during a migration from v4 to v5. The getter of the subscription status will attempt to make a change to the model, which will then be queued in the model update operation. This operation requires onesignal_id to be completed, but the id is null at the early stage. To prevent the access of onesignal_id when it is null in the early init process, this fix will add a default subscription status in case of its absence under the NO_PROPOGATE tag.
Testing
Manual testing
Step to reproduce:
After the fix, the crash no longer exists. Some normal OneSignal operations such as logging in, logging out, sending and receiving push notifications are all working properly.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is