Skip to content
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

Add support for in-app notifications. #6341

Merged
merged 2 commits into from
Jul 7, 2022

Conversation

pixlwave
Copy link
Member

@pixlwave pixlwave commented Jun 24, 2022

The old in app notifications UI from the app delegate was an alert which was rather obtrusive. However PushNotificationService includes a way for a notification to request native in-app presentation (and makes sure to only do so if the room is not currently visible). This PR adds a setting that is checked in the service alongside the notification content and removes the old UI.

Could do with direction from Product on whether

  1. A setting is definitely needed or this should be always on?
  2. If the setting is kept, whether it should be enabled or disabled by default?
  3. The string (re-used from MatrixKit) should be updated to use sentence case like the other settings?
  4. If the setting should go further down in the list (looking at it now I think it should probably come after the "Device notifications" row)?

Fixes #1108.

Settings Notification
IMG_0422 IMG_0423

@pixlwave pixlwave added the X-Needs-Product Requires input from the product team label Jun 24, 2022
@@ -347,7 +347,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNot
{
completionHandler(UNNotificationPresentationOptionBadge
| UNNotificationPresentationOptionSound
| UNNotificationPresentationOptionAlert);
| UNNotificationPresentationOptionBanner);
Copy link
Member Author

@pixlwave pixlwave Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Alert option was deprecated in iOS 14. I'm not sure what this means for the Constants.userInfoKeyPresentNotificationOnForeground check: one change could be to include it in notification centre too if that is set, but that didn't seem worthwhile to me.

@github-actions
Copy link

github-actions bot commented Jun 24, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/WQGm4c

@pixlwave pixlwave requested a review from amshakal June 27, 2022 15:36
@amshakal
Copy link

amshakal commented Jul 6, 2022

Hi there, thanks for working on this. Here is my repsonse to the questions:

  • A setting is definitely needed or this should be always on? - A setting should be there for this
  • If the setting is kept, whether it should be enabled or disabled by default? - Can we enable this if the user selects 'allow notifications'?
  • The string (re-used from MatrixKit) should be updated to use sentence case like the other settings? - Sure! :D
  • If the setting should go further down in the list (looking at it now I think it should probably come after the "Device notifications" row)? - Yes, that seems right

Additionaly, I would imagine that the notification banner will have the avatar of the user and not element's logo?

@daniellekirkwood let me know if you disagree with any of this.

@pixlwave
Copy link
Member Author

pixlwave commented Jul 6, 2022

Super thanks for the feedback.

Can we enable this if the user selects 'allow notifications'?

Yep, it will only work if the user allows notifications, so leaving it as enabled by default with give this exact behaviour.

Additionaly, I would imagine that the notification banner will have the avatar of the user and not element's logo?

Sadly this is the system notification banner so it is shown as is. However! There is an issue (#4710) and an oldish community PR (#4819) to enable this style on iOS 15, so there is potential this will happen separately at some stage.

Updated Settings Screen:
IMG_8F867FCA4DD6-1

@pixlwave pixlwave requested review from a team and Anderas and removed request for a team July 6, 2022 13:43
@sonarcloud
Copy link

sonarcloud bot commented Jul 6, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@pixlwave pixlwave removed the X-Needs-Product Requires input from the product team label Jul 6, 2022
Copy link
Contributor

@Anderas Anderas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great action. One thing I am not clear on is the check to not show notifications for the currently open room. Where is this implemented?

@@ -2656,100 +2618,6 @@ - (UIViewController*)presentedViewController

#pragma mark - Matrix Accounts handling

- (void)enableInAppNotificationsForAccount:(MXKAccount*)account
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice chunk of code gone 🎉

@pixlwave
Copy link
Member Author

pixlwave commented Jul 7, 2022

One thing I am not clear on is the check to not show notifications for the currently open room. Where is this implemented?

There's a check on LegacyAppDelegate.visibleRoomId which is set/cleared by RoomViewController when the room appears/disappears.

@pixlwave pixlwave merged commit 00d781a into develop Jul 7, 2022
@pixlwave pixlwave deleted the doug/1108-in-app-notifications branch July 7, 2022 14:31
@Anderas
Copy link
Contributor

Anderas commented Jul 7, 2022

One thing I am not clear on is the check to not show notifications for the currently open room. Where is this implemented?

There's a check on LegacyAppDelegate.visibleRoomId which is set/cleared by RoomViewController when the room appears/disappears.

Ah indeed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-app notifications
3 participants