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 communication Notification context to message notifications #4819

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

kloenk
Copy link
Contributor

@kloenk kloenk commented Sep 10, 2021

Pull Request Checklist

  • I read the contributing guide
  • UI change has been tested on both light and dark themes, in portrait and landscape orientations and on iPhone and iPad simulators
  • Pull request is based on the develop branch
  • Pull request contains a changelog file in ./changelog.d
  • Pull request includes screenshots or videos of UI changes
  • Pull request includes a sign off

@pixlwave
Copy link
Member

Related issue: #4710

I'll have a look through this next week, although given that the CI very much needs Xcode 13, no promises on how long it would be until we could merge it.

@kloenk kloenk force-pushed the communication branch 2 times, most recently from c1f42b8 to 67399c5 Compare September 10, 2021 19:37
Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

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

Hey Finn, thanks very much for this contribution. 🤩

I've had a look through and added a few comments (not yet set up to test it out in action). It may be a while until we're ready to adopt Xcode 13 for our releases so merging won't be possible until then, but I'd be very happy to iterate on this with you in the mean time 🙂

One comment not added inline is that it would be desirable for this update to not change the behaviour of notifications for iOS 14 and lower, e.g. keep the title to display "Sender in Room"

@@ -581,6 +591,9 @@ class NotificationService: UNNotificationServiceExtension {
if let title = title {
notificationContent.title = title
}
if let subTitle = subTitle {
notificationContent.subtitle = subTitle
Copy link
Member

@pixlwave pixlwave Sep 16, 2021

Choose a reason for hiding this comment

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

Would you be able to make the various uses of subtitle all lower case, so that they match the UNNotificationContent property?

Suggested change
notificationContent.subtitle = subTitle
notificationContent.subtitle = subtitle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think I meant to do it, but coding to fast :-)

notificationTitle = self.messageTitle(for: eventSenderName, in: roomDisplayName)
notificationTitle = eventSenderName
}
if !(roomSummary?.isDirect ?? false) {
Copy link
Member

Choose a reason for hiding this comment

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

Could these tests match the old logic from the messageTitle/replyTitle methods and compare sender name to room name:
if let roomDisplayName = roomDisplayName, roomDisplayName != eventSenderName {
This would avoid duplicating the title into the subtitle for 1:1 rooms that aren't DMs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I rememberer I had one direct message room, which failed this test. But I can't find it right now, so yeah. Can use the old test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, just had a notification where this check failed (build from the AppStore, did not show the room name, but only the sender name)

self.bestAttemptContents[event.eventId] = content
if let notificationContent = notificationContent {
// TODO: this will most likely break the notification context maybe there is a better way
self.bestAttemptContents[event.eventId] = notificationContent.mutableCopy() as? UNMutableNotificationContent
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to leave it how it was before? I guess the removed block above doesn't copy the extra data filled from the Intent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the internal type does change. And apple says don't touch it.

if event.isVoiceMessage() {
return .outgoingMessageAudio
}
return .unknown
Copy link
Member

Choose a reason for hiding this comment

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

The docs for .outgoingMessageAudio say "An audio recording". Could this cover all audio messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably, will change it

}

@available(iOS 14, *)
private func getMessageIntentType(_ msgType: String?, _ event: MXEvent) -> INOutgoingMessageType {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private func getMessageIntentType(_ msgType: String?, _ event: MXEvent) -> INOutgoingMessageType {
private func messageIntentType(for msgType: String?, _ event: MXEvent) -> INOutgoingMessageType {



@available(iOS 15, *)
private func getMessageIntent(forEvent event: MXEvent,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private func getMessageIntent(forEvent event: MXEvent,
private func messageIntent(forEvent event: MXEvent,

self.makeCommunicationNotification(
forEvent: event,
// TODO: use real room/user avatar
senderImage: INImage.systemImageNamed("person.circle.fill"),
Copy link
Member

Choose a reason for hiding this comment

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

If this was nil would it give the full sized app icon until the real avatar is available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I still did not figure out what one should do there. So if nil or this is the better approach

Copy link
Member

@pixlwave pixlwave Sep 16, 2021

Choose a reason for hiding this comment

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

I'd go with nil for now as it will look familiar. Having a template image may give the impression that something has broken.

@pixlwave
Copy link
Member

One comment not added inline is that it would be desirable for this update to not change the behaviour of notifications for iOS 14 and lower, e.g. keep the title to display "Sender in Room"

Just wondering, as the intent is only created for message events, perhaps at the appropriate point around here maybe it would make sense to do a check for iOS 15 and update the content with an intent, otherwise carry on as before?

@kloenk
Copy link
Contributor Author

kloenk commented Sep 16, 2021

Just wondering, as the intent is only created for message events, perhaps at the appropriate point around here maybe it would make sense to do a check for iOS 15 and update the content with an intent, otherwise carry on as before?

I would like to add the call events rather soon, just did not get around to it yet.

(I will try to add your comment's this weekend, uni just started for me 😄 )

@pixlwave
Copy link
Member

I would like to add the call events rather soon, just did not get around to it yet.

(I will try to add your comment's this weekend, uni just started for me 😄 )

Ah, yes that makes sense then. No rush, have fun! 🎓

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants