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

Notification Service Extension is broken when the session is signed out, then signed in #3719

Closed
giomfo opened this issue Oct 2, 2020 · 4 comments · Fixed by #3873
Closed
Assignees
Labels
T-Defect Something isn't working: bugs, crashes, hangs and other reported problems

Comments

@giomfo
Copy link
Member

giomfo commented Oct 2, 2020

Element iOS v1.0.14

This issue may be related to #3718

To reproduce:
1- Connect your account on an iOS device
2- Enable the notifications and turn on the option "Show decrypted content"
3- Put the application in the background
3- Send messages in an encrypted room from another account -> Messages are displayed decrypted in the notification panel: OK
4- Sign out
5- Sign in
6- Send messages in an encrypted room from another account -> The NSE fails to decrypt the message. A simple message "Message" is displayed in the notification panel: NOK
Bing are broken for this reason too.
Note: The room name is displayed.

I think the NSE fails to get the keys of this new session

I was not able to repair the push notifications, and I had to uninstall the application...

@giomfo giomfo added the T-Defect Something isn't working: bugs, crashes, hangs and other reported problems label Oct 2, 2020
@manuroe manuroe added this to the Sprint 32 milestone Oct 5, 2020
@csett86
Copy link
Contributor

csett86 commented Oct 24, 2020

I can confirm this bug on the current iOS app store version 1.0.16.

In addition the push notifications are also broken after signout/signin in unencrypted rooms, so in total in all rooms the notification preview is no longer working. Only "Message in $roomname" is displayed.

From my initial log analysis it looks like the session is reused even though the access token is no longer valid (due to logout). So that looks like the new session after logout&login is never set up in the NSE:

standard	23:54:53.984899+0200	RiotNSE	[NotificationService] Instance: <RiotNSE.NotificationService: 0x105a6f690>, thread: <NSThread: 0x105a5ee80>{number = 3, name = (null)}
standard	23:54:53.985454+0200	RiotNSE	[im.synod] Getting delivered notifications
standard	23:54:53.985820+0200	RiotNSE	[NotificationService] Payload came: [AnyHashable("event_id"): $vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0, AnyHashable("unread_count"): 1, AnyHashable("room_id"): !REDACTED:REDACTED.org, AnyHashable("aps"): {
    alert =     {
        "loc-args" =         (
        );
        "loc-key" = MESSAGE;
    };
    "mutable-content" = 1;
}]
standard	23:54:53.986597+0200	RiotNSE	[NotificationService] Instance: Reusing session
standard	23:54:53.993320+0200	RiotNSE	[MXHTTPClient] #7 - GET _matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/%24vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0
standard	23:54:53.993890+0200	RiotNSE	Task <DFDBE0EE-46BD-4621-8D09-D986B85A99A2>.<7> resuming, QOS(0x15)
standard	23:54:54.006872+0200	RiotNSE	[im.synod] Got 2 delivered notifications [ hasCompletionHandler: 1 ]
standard	23:54:54.007316+0200	RiotNSE	[UNUserNotificationCenter] removeUnwantedNotifications: Removing 0 notifications.
standard	23:54:54.007688+0200	RiotNSE	[im.synod] Removing 0 delivered notifications with identifiers (
)
...
standard	23:54:54.321314+0200	RiotNSE	[MXHTTPClient] #7 - GET _matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/%24vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0 completed in 329ms
standard	23:54:54.321768+0200	RiotNSE	[MXHTTPClient] Request 0x10582ac90 failed for path: _matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/%24vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0 - HTTP code: 401. Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo={NSLocalizedDescription=Request failed: unauthorized (401), NSErrorFailingURLKey=https://synod.im/_matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/%24vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0, com.alamofire.serialization.response.error.data=<7b226572 72636f64 65223a22 4d5f554e 4b4e4f57 4e5f544f 4b454e22 2c226572 726f7222 3a22556e 7265636f 676e6973 65642061 63636573 7320746f 6b656e22 2c22736f 66745f6c 6f676f75 74223a66 616c7365 7d>, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x105a5a3b0> { URL: https://synod.im/_matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/%24vdL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0 } { Status Code: 401, Headers {
    "Access-Control-Allow-Headers" =     (
        "Origin, X-R
standard	23:54:54.322678+0200	RiotNSE	[MXHTTPClient] Error JSONResponse: {
    errcode = "M_UNKNOWN_TOKEN";
    error = "Unrecognised access token";
    "soft_logout" = 0;
}
standard	23:54:54.323337+0200	RiotNSE	[MXHTTPClient] cleanupBackgroundTask
standard	23:54:54.325387+0200	RiotNSE	[NotificationService] fetchEvent: MXSession.event method returned error: Optional(Error Domain=org.matrix.sdk Code=6 "Unrecognised access token" UserInfo={errcode=M_UNKNOWN_TOKEN, NSLocalizedDescription=Unrecognised access token, httpResponse=<NSHTTPURLResponse: 0x105a5a3b0> { URL: https://synod.im/_matrix/client/r0/rooms/!REDACTED:REDACTED.org/event/2dL2WhFWHx8k5wdMY6Peyph4IV6zLOj07ZFn9OtPBT0 } { Status Code: 401, Headers {
    "Access-Control-Allow-Headers" =     (
        "Origin, X-Requested-With, Content-Type, Accept, Authorization"
    );
    "Access-Control-Allow-Methods" =     (
        "GET, HEAD, POST, PUT, DELETE, OPTIONS"
    );
    "Access-Control-Allow-Origin" =     (
        "*"
    );
    "Cache-Control" =     (
        "no-cache, no-store, must-revalidate"
    );
    Connection =     (
        "Keep-Alive"
    );
    "Content-Type" =     (
        "application/json"
    );
    Date =     (
        "Sat, 24 Oct 2020 21:54:54 GMT"
    );
    "Keep-Alive" =     (
        "time<…>
standard	23:54:54.328794+0200	RiotNSE	[NotificationService] fallbackToBestAttemptContent: method called.
standard	23:54:54.332587+0200	RiotNSE	[7BA45717-F921-4365-8340-4F65080F72A3] Received replacement content for notification request D0EB-3441 [ hasContent: 1 attachments: 0 ]
standard	23:54:54.332823+0200	RiotNSE	[7BA45717-F921-4365-8340-4F65080F72A3] Cleaning up extension

@csett86
Copy link
Contributor

csett86 commented Oct 24, 2020

In addition I could reproduce this in the a build resembling the previous iOS App Store version 1.0.12, so this could be a long standing bug.

csett86 added a commit to luki-ev/synod-ios that referenced this issue Oct 25, 2020
@Logicwax
Copy link

Logicwax commented Nov 6, 2020

I had this exact same problem too, glad it wasn't just me. Tried uninstalling and reinstalling. Same problem. Just keeps showing "Message" instead of actual decrypted message content.

@Logicwax
Copy link

I just fixed this by turning off PIN and FaceID. Now my push messages are all decrypted now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Defect Something isn't working: bugs, crashes, hangs and other reported problems
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants