MacOS notifications not working as expected: showing fallback notifications if explicitly disallowed, showing no notifications if allowed #4989
Labels
unverified
A bug that has been reported but not verified
Checklist
Describe the bug
Just before the first notification is shown, a system alert is shown to notify the user of the app wanting to send notifications. On hoovering, it shows a closing x and a dropdown
Options
withAllow
andDon't Allow
.If I explicitly disallow to send notifications, it will subsequently show fallback notifications instead. That is not what should happen. The app should not show any notifications.
If I explicitly allow to send notifications I receive no further notifications. No 'official' notifications and no fall back notifications.
If I just close the notification (clicking the top left x on hoovering) without choosing any of the options, then the effect is the same as disallowing.
How to reproduce
I have a simple notifications app. I create a
fyne release
version and install the resulting .pkg file on MacOS.Screenshots
Example code
Fyne version
2.4.5
Go compiler version
go version go1.21.5 darwin/amd64
Operating system and version
MacOS Sonoma 14.5 (Intel)
Additional Information
When disallowed the fallback is shown because the OS additionally gives an error even when granted is clearly false:
Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}
The code in
app_darwin.m
will therefore trigger falsely the fallback. The comment in the code is not correct. The error will also be produced if the app is signed but the user disallows notifications:I also found an explanation why notifications do not show. At least on my MacBook.
Fyne explicitly asks permission for Alerts. The OS then asks permission: 'Notifications may include alerts, sounds and icon badges'. So this also includes alerts.
So why are the alerts not shown?
If I go to Settings -> Notifications -> test app, it does not show Alerts as an option. It shows Banners. See the screenshot. So for some reason MacOS (on my system?) defaults to allowing banners only, while the Fyne app is sending alerts. Because when I manually switch the app settings from allowing Banners to Alerts, the notifications suddenly show!
Is it something in my system that defaults to allowing banners only? Do Fyne notifications work out of the box for others?
If this is not specific to my system: in the code Fyne sends notifications without explicit setting to banner and/or alert. So it seems the notifications implicitly are treated as alerts while only banners are allowed?
The text was updated successfully, but these errors were encountered: