-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle if push notification doesn't have a payload #47123
Conversation
@jp928 Please do not raise PRs until assigned in the issue |
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we have a type error, pushPayload.extras.payload
is shown to have type JsonValue
but it's not always the case as it can be undefined
. I think we should fix this upstream. Then we can just fix the ts errors which will prevent the crash.
This assertion is also false
const data = payload as PushNotificationData
@arosiclair @s77rt Updated with respecting comments. |
@jp928 Did you raise a PR? (#47123 (comment)) |
|
@jp928 Can you please create a patch so we can have the type corrected without waiting for the upstream PR to be merged |
@s77rt I can get an airship patch out today with the PR |
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please apply same solution for other affected places (in editor search for: as PushNotificationData
)
Thx. Just apply same cast as other places. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the airship package getting updated with this fix soon? If so, can we just use the new version instead of adding this patch?
This is not what I meant. Actually the new cast is the correct one. What I meant is that in other places the payload can be undefined and we are still accessing fields on undefined e.g.
|
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
@jp928 The QA steps are not clear (sending a notification without payload). Can you instead use the steps from the reported issue? |
@jp928 Did you find a way to send a notification to the Android Emulator? |
Unfortunately no. |
@jp928 In QA Steps add a third step to verify that the app didn't crash |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: Nativeios.moviOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
src/libs/Notification/PushNotification/shouldShowPushNotification.ts
Outdated
Show resolved
Hide resolved
@jp928 Looks we have conflicts |
…ive-ariship version,
Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com>
Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com>
…ion.ts Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com>
…ion.ts Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com>
1adac8c
to
efffbe9
Compare
@jp928 For future PRs please avoid force-pushing, it causes review progress to be lost and can't use the "Show changes since your last review" option. Instead merge |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/arosiclair in version: 9.0.25-0 🚀
|
1 similar comment
🚀 Deployed to staging by https://github.com/arosiclair in version: 9.0.25-0 🚀
|
Details
If a push notification was send without a payload, the App would crash.
Fixed Issues
$ #46820
PROPOSAL: $ #46820 (comment)
Tests
Offline tests
npm run ios
QA Steps
1.Get a Hybrid App notification that an expense report has been reimbursed
2.Unlock phone (not even specifically opening the notification)
3. Verify that the app doesn't crash
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
andrid_native.webm
Android: mWeb Chrome
android_web.webm
iOS: Native
Screen.Recording.2024-08-09.at.10.09.15.AM.mov
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.15.-.2024-08-09.at.10.16.09.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-08-09.at.10.17.36.AM.mov
MacOS: Desktop
Screen.Recording.2024-08-09.at.10.22.21.AM.mov