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 interactive notifications (fixes #625) #1777

Merged
merged 4 commits into from
Feb 26, 2018

Conversation

joeywatts
Copy link

@joeywatts joeywatts commented Feb 20, 2018

This adds interactive notifications, so that you can quickly reply to messages from the notification. Visually, the feature looks and works exactly like WhatsApp's notification action. If you have the "Show decrypted content" setting turned off, the quick reply functionality is disabled for encrypted notifications (since it doesn't make sense to reply to a message before actually seeing its content).

#625

Signed-off-by: Joey Watts [email protected]

@manuroe manuroe changed the base branch from master to develop February 20, 2018 13:59
@joeywatts joeywatts changed the title Add support for interactive notifications Add support for interactive notifications (fixes #625) Feb 20, 2018
Copy link
Member

@manuroe manuroe left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. We just need some adjustments to complete it.

Could you please sign-off it as per https://github.com/vector-im/riot-ios/blob/master/CONTRIBUTING.rst?

if (responseText != nil && responseText.length != 0)
{
NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: sending message to room: %@", roomId);
[room sendTextMessage:responseText success:^(NSString* eventId) {} failure:^(NSError* error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the sendTextMessage method of MXKRoomDataSource, instead?
It does a bit more processing on text before sending. Plus, it will manage local echo if the user opens the room while the message is being sent.

{
NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: sending message to room: %@", roomId);
[room sendTextMessage:responseText success:^(NSString* eventId) {} failure:^(NSError* error) {
NSLog(@"[AppDelegate][Push] handleActionWithIdentifier: error sending text message: %@", error);
Copy link
Member

Choose a reason for hiding this comment

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

How to deal better with the error? Is it possible to display it to the end user?
My concern is e2e rooms where sending can fail because there are new devices in a room. The sending fails because the user has not validated those new devices yet.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I encountered that issue in my testing... Couldn’t figure out how to properly notify the user. How about another local notification that indicates there was an error sending the message?

Copy link
Member

Choose a reason for hiding this comment

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

This is a good idea. The user should be able to go the room when clicking on this notification.

Then, the app will automatically propose them to resend the message. This failure flow seems not too bad.

Copy link
Member

@manuroe manuroe left a comment

Choose a reason for hiding this comment

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

Thanks for the update. We are close to the solution.
Do not forget to sign-off.

MXKRoomDataSourceManager* manager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:account.mxSession];
if (manager)
{
roomDataSource = [manager roomDataSourceForRoom:roomId create:false];
Copy link
Member

Choose a reason for hiding this comment

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

We need create:YES to make sure we will have an instance of MXKRoomDataSource.
But we cannot call it in this loop because we will have instance even if the MXSession does not know the room.

So we need to come back to the previous lookup with room = [account.mxSession roomWithRoomId:roomId];. Something like

            MXKRoomDataSource* roomDataSource = nil;
            for (MXKAccount* account in mxAccounts)
            {
                MXRoom *room = [account.mxSession roomWithRoomId:roomId];
                if (room)
                {
                    MXKRoomDataSourceManager* manager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:account.mxSession];
                    if (manager)
                    {
                        roomDataSource = [manager roomDataSourceForRoom:roomId create:YES];
                    }
                    break;
                }
            }

@manuroe manuroe merged commit d91e2f9 into element-hq:develop Feb 26, 2018
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.

2 participants