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
Improve logic for push notification tap routing #4143
Conversation
- Push onto main navigation controller stack (do not pop to root first) - Present a confirmation alert before routing if any editing view is displayed
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.
Nice! As discusssed in planning, I tested all the routes but primary focused on editing related navigation and will rely on QA to do a deeper dive. Merges conflict to resolve, a note, and a question in review.
This is easiest to test by triggering fake notifications to a test device through our internal push utility tool.
You know I love the push utility! But by the way, there's another simple way to test this routing via the Simulator. The Simulator supports accepting simulated payloads. While I don't believe it goes through our service extension, it at least provides a quick debug cycle.
First you need to construct some kind of test payload.apns
like this:
{
"aps": {
"alert": {
"title": "Notification",
"body": ""
}
}
}
And via the Terminal, you can push the payload to the Simulator. This will work if you only have one Simulator booted:
xcrun simctl push booted org.wikimedia.wikipedia payload.apns
} | ||
|
||
fileprivate extension UIViewController { | ||
var isPartOfEditorFlow: Bool { |
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.
Should we also consider writing a User talk discussion reply as part of the editing flow as well? Currently, tapping a notification when replying to a User talk discussion dismisses that to show the Notifications Center.
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.
Great catch! I added this work to my latest commit. The awkward thing is that the talk page new topic and reply screens push on from the right, so the user actually doesn't lose their changes unless they're somehow already in a modal, say, from visiting your talk page in Settings. So I'm only displaying an alert if they are in a talk page from Settings right now (or any other modal, but I think this is the only place it can happen). Let me know what you think - it still feels a bit weird to me.
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.
Looks great - I'm glad the protocol approach felt like the right path forward to you too! Only a few tiny notes below and 2 merge conflicts to resolve.
|
||
/// View Controllers that have an editing element (Section editor flow, User talk pages, Article description editor) | ||
protocol EditingFlowViewController where Self: UIViewController { | ||
var shouldDisplayAlert: Bool { get } |
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.
Because all these interested objects are gonna inherit this property, I'd recommend we take a page out of Objective-C's book and be a bit more verbose about what we call this in an effort to 1. be more explicit about what it controls and 2. prevent unintended misuse of the property in future work in these controllers.
Just a couple ideas: shouldDisplayDiscardEditsAlert
, shouldDisplayExitConfirmationAlert
, something like that?
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.
Good idea! I went with shouldDisplayExitConfirmationAlert
for this
|
||
|
||
/// View Controllers that have an editing element (Section editor flow, User talk pages, Article description editor) | ||
protocol EditingFlowViewController where Self: UIViewController { |
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 where Self: UIViewController
conditional conformance actually needed here?
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.
@staykids I don't think it's needed to compile, but I liked constraining them to UIViewController
because I am only considering UIKit view controllers when looking around in the navigation hierarchy for these types (within editingFlowViewControllerInHierarchy
and notificationsCenterFlowViewController
. I did initially try an option with no constraint and conformed the NotificationsCenterFilterView
and NotificationsCenterInboxView
SwiftUI structs to it, but I had a hard time checking for that conformance from WMFAppViewController. I may just be missing something with SwiftUI / UIKit interop though.
} | ||
|
||
/// View Controllers that are a part of the Notifications Center flow | ||
protocol NotificationsCenterFlowViewController where Self: UIViewController { |
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.
Same note as above re: conditional conformance.
@staykids thanks for the suggestions! This is ready for another look. |
Phabricator:
https://phabricator.wikimedia.org/T287628
Notes
This makes the push notification tap routing a little bit smarter, taking into account the user's editing state and presenting a confirmation alert before routing. It also no longer pops to the main navigation controller's root before routing, so we're no longer wiping out their rabbit hole.
Test Steps
This is easiest to test by triggering fake notifications to a test device through our internal push utility tool. Reach out to me if you need help setting that up. Once you're able to send notifications to device, use these steps to test various configurations. If you think of any others, feel free to test those too.