[expo-notifications] If unmarshaling notification request fails always try to naively reconstruct the request #10801
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.
Why
Current code doesn't try to reconstruct the notification request if we aren't able to read notification request from the existing byte array which is supposed to hold marshaled notification request. By removing the
if-else
in favor of…return…
we ensure that the method returns a nonnull value for more arguments.This also lets us override this method in a more natural way.
How
Instead of trying to reconstruct
NotificationRequest
fromStatusBarNotification
only if there is noExpoNotificationBuilder.EXTRAS_MARSHALLED_NOTIFICATION_REQUEST_KEY
extra value, let's try to do it if we fail to read the extras value too.Test Plan
test-suite
passes related tests.