Open blueturtleai opened 8 months ago
I observed this now for some days. My impression is, that it only happens, if the app is in foreground when the notification arrives. Not sure, if this helps and if it is even possible.
Iām more and more sure, that duplicate count only occurs, if the app is in foreground.
To better understand, if this could really happen, I read a bit about iOS notifications. And here comes my theory: it seems, your app listens to remote notifications. Is there a second listener for foreground notifications? If so, both listeners could be triggered, which leads to a duplicate count.
Iām not an iOS developer, so this is only a wild guess š. Would like to hear your opinion.
I'll check everywhere I increase the count when I'll work on this issue. Thanks for all the detail it'll really make it easy to solve!
I had now a look at the code and I think I understand now why it happens:
StreamWatcher.swift 101
self.unreadNotificationsCount += 1
NotificationService.swift 73
currentCount += 1 preferences.notificationsCount[token] = currentCount
AppView.swift 103
return watcher.unreadNotificationsCount + (userPreferences.notificationsCount[token] ?? 0)
If the app is in foreground, StreamWatcher AND NotificationService are triggered. watcher.unreadNotificationsCount and userPreferences.notificationsCount are increased by 1. Both values are added and displayed as badge in AppView. To fix it, unreadNotificationsCount shouldn't be increased, if the app is in foreground.
Not sure, if this the right way to fix it, but I think I have identified the cause for this issue correctly. At least I hope so š.
This is happening really frequently on macOS too; I'll have a notification come in and I'll view it in the app, but a badge remains in the dock showing 1 notification (sometimes it's properly marked as read, but then the badge comes back a second later)
Environment:
Description
In many cases the notification counter shows the double amount of notifications. For example it shows 2, but when I check the notification tab, there is only 1 new notification. I also only get 1 push alert. I have got several accounts, maybe the problem is connected to that.