App icon badge notification count is wrong.
Steps to reproduce
The badge count on the icon is calculated by the server, not by the app, and so tends to be wrong.
Outcome
What did you expect?
Reliable app icon badge count
What happened instead?
We had https://github.com/element-hq/element-x-ios/issues/2066, but that was exacerbated by a synapse bug now fixed. The overall design problem from https://github.com/matrix-org/matrix-spec-proposals/pull/4076 is still there though, and so the badge counts continue to be wrong...
Your phone model
No response
Operating system version
No response
Application version
675
Homeserver
No response
Will you send logs?
No
I have suffered from this bug many times! I can accept that this is generally problematic, but going forward, is there any way to force reset the count from Synapse when this issue arises? Otherwise, could some reset cache button be added as an escape hatch as I believe resolves this is regular Element?
Otherwise, could some reset cache button be added as an escape hatch as I believe resolves this is regular Element?
This wouldn't help as the app would still be using the count from Synapse I'm afraid.
@pixlwave But this is what I can't understand - I don't see this badge issue on any other client than Element X for iOS: even installing Element X on macOS results in the correct badge count. All regular Element clients also display it correctly. It's literally only Element X on my phone 🤷
Element iOS is using the badge number from Synapse until you open the app at which point it computes the badge locally as it has a copy of all the messages to use. Element X on the other hand is using Sliding Sync and with this, we don't (yet) have the code to fetch all of the necessary messages in order to do the computation locally.
Ah I see. Ok thanks, that makes more sense
This is super annoying and there seems to be nothing I can do besides disallow the badge.
Is there any progress towards resolution of this very annoying issue ?
An interesting approach has been proposed by Danny in the Matrix Rust SDK Development room.
I have the same issue since moving from Element to Element X.
On the dekstop app the badge count is correct, but on all my devices with Element X, there is an offset of +1 notification always.
I'm having the same issue. I have a badge count of 8 that I cannot clear.
I gave up on the badge count some time ago. I just disable it in iOS app settings
I am not sure this is the same issue as #4365 as I do not have a fixed offset, but the number is stuck at 2 no matter how many messages I get. Am I missing something about this bug report?
I am not sure this is the same issue as #4365 as I do not have a fixed offset, but the number is stuck at 2 no matter how many messages I get. Am I missing something about this bug report?
Same here
Friendly ping @maintainers - are there any logs or tests I can perform to help you replicate this issue? I am a senior python developer with lots of backend experience, so I'm pretty handy around dev tools, but I have next to no experience with Swift, and the last time I wrote Obj-C and touched Xcode was probably around 20 years ago…
are there any logs or tests I can perform to help you replicate this issue?
Hi Martin, thanks for offering to help but this has always mostly been a backend issue, with synapse sometimes not updating unread counts and forcing the wrong value to the client. While https://github.com/matrix-org/matrix-spec-proposals/pull/4076 and an implementation for it exists we would still need to locally compute the counts, which is currently blocked behind an improved cross process lock (NSE vs. the main app).
Luckly synapse is python but I wouldn't know where to start, perhaps issues like https://github.com/element-hq/synapse/issues/15698
@stefanceriu I just noticed that I responded to this bug instead of #4365 as I intended to, as I cannot yet actually reproduce this issue. Sorry for the mixup. But I would appreciate some advice on how to help for the other bug.
👋 I'm working on it: https://github.com/matrix-org/matrix-rust-sdk will provide what's needed for Element X to get a correct count value.
@Hywan Please feel free to ping me if there is anything I can help test or provide logs for.
@dwt Thanks :-)!
@Hywan Any updates?
When will this issue be resolved?
@hogger0's message reminded me of this. I turned off icon badging on iOS years ago because of this. Considering the leaps and bounds Element X iOS has taken recently (now becoming a really nice native chat client), that this incredibly fundamental issue still persists is really very frustrating and undermining
No update yet. I've been off for 3 weeks, but I'm resuming my work now. A couple of other stuff needed to be done before continuing working on this. We are progressing :-). Keep an eye on This Week In Matrix, could be fun.
That's amazing news. I'm sure everyone here is looking forward to the result
Like I do!
I was able to "fix" this from the server side by sending read receipts to rooms that had notifications in the sync query.
Kind of a huge pain, made somewhat easier by using matrix-commander and jq.
After pulling & configuring matrix-commander, the process was something like:
# Use the "sync" endpoint to get joined room IDs having non-zero unread notification counts (this might take a minute)
docker run --network=<docker_matrix_server_network> --rm -v ./:/data:z matrixcommander/matrix-commander --rest GET "" "http://<server>:<port>/_matrix/client/r0/sync?access_token=__access_token__" | jq '.rooms.join | map_values(select(.unread_notifications.notification_count != 0)) | keys[]' -r
# Get the latest message 'event_id' from a particular 'room_id' (hopefully that "event" is the most recent)
docker run --network=<docker_matrix_server_network> --rm -v ./:/data:z matrixcommander/matrix-commander --rest GET "" "http://<server>:<port>/_matrix/client/r0/rooms/<room_id>/messages?access_token=__access_token__&dir=b&limit=1" | jq -r '.chunk[0].event_id'
# Send a receipt message in that 'room_id' for that 'event_id'
docker run --network=<docker_matrix_server_network> --rm -v ./:/data:z matrixcommander/matrix-commander --rest POST "{}" "http://<server>:<port>/_matrix/client/r0/rooms/<room_id>/receipt/m.read/<event_id>?access_token=__access_token__"
Edit: One can pull out the room_id and event_id from the initial call to sync with something like this:
# Added a "filter" parameter to get just the latest event for each room of either 'm.reaction' or 'm.room.*' types
docker run \
--network=<docker_matrix_server_network> \
--rm \
-v ./:/data:z matrixcommander/matrix-commander \
--rest GET "" "http://<server>:<port>/_matrix/client/r0/sync?access_token=__access_token__&filter={\"room\":{\"timeline\":{\"limit\":1,\"types\":[\"m.room.*\",\"m.reaction\"]}}}" | \
# jq prints each 'room_id' and its latest 'event_id'
jq '.rooms.join as $rooms_join | $rooms_join | map_values(select(.unread_notifications.notification_count != 0)) | keys[] | . as $room_id | $rooms_join[$room_id].timeline.events[0].event_id | "\($room_id) \(.)"' -r