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

MacOS not asking for permission to show notifications #4974

Open
2 tasks done
Gys opened this issue Jun 25, 2024 · 1 comment
Open
2 tasks done

MacOS not asking for permission to show notifications #4974

Gys opened this issue Jun 25, 2024 · 1 comment
Labels
unverified A bug that has been reported but not verified

Comments

@Gys
Copy link

Gys commented Jun 25, 2024

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

If I create and show a notification on my Mac, it shows an osascript commandline created notification. Confusing, because the icon is different from my app and, more problematic, it contains an 'open' button which opens an empty 'Script editor' folder when clicked...

Looking at the code I find this a fallback method for showing notifications.

I did not understand why the fallback was shown because the code is explicitly first asking for permission and if allowed should show normal notifications.

Looking in the app log I find this:

2024-06-25 12:08:28.632115+0100 0x2f4640a  Error       0x0                  32374  0    usernotificationsd: (UserNotificationsCore) [com.apple.usernotificationsd:Connections] [nil] Entitlement 'com.apple.private.usernotifications.bundle-identifiers' required to request user notifications
2024-06-25 12:08:28.632303+0100 0x2f4640a  Error       0x0                  32374  0    usernotificationsd: (UserNotificationsCore) [com.apple.usernotificationsd:Connections] [nil] setObservingUserNotifications not allowed: io.guidu2.app
2024-06-25 12:08:28.632741+0100 0x2f4640a  Error       0x0                  32374  0    usernotificationsd: (UserNotificationsCore) [com.apple.usernotificationsd:Connections] [nil] Entitlement 'com.apple.private.usernotifications.bundle-identifiers' required to request user notifications
2024-06-25 12:08:28.652991+0100 0x2f4640a  Error       0x0                  32374  0    usernotificationsd: (UserNotificationsCore) [com.apple.usernotificationsd:Connections] [nil] requestAuthorization not allowed: io.test2.app
2024-06-25 12:08:28.654569+0100 0x2f46129  Default     0x0                  27974  0    notifications: (UserNotifications) [com.apple.UserNotifications:Connections] [io.test2.app] Requested authorization [ didGrant: 0 hasError: 1 hasCompletionHandler: 1 ]
2024-06-25 12:08:28.655571+0100 0x2f46129  Default     0x0                  27974  0    notifications: Fyne error asking for permission to send notifications Error Domain=UNErrorDomain Code=1 "(null)"

So it seems the app is not properly setup to ask for permission?

I found this Apple document that might relate to this:
https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_aps-environment

It says To add this entitlement to your app, enable the Push Notifications capability in Xcode.. So I assume this requires a change in the xcode project that is used for building darwin apps.

How to reproduce

Create a minimal notification app. Build for darwin and run on MacOS.

Screenshots

No response

Example code

func main() {
	a := app.New()
	w := a.NewWindow("Notification Example")
	btn := widget.NewButton("Show Notification", func() {
		notification := fyne.NewNotification("Notification Title", "This is the notification.")
		a.SendNotification(notification)
	})
	w.SetContent(container.NewVBox(
		widget.NewLabel("Click the button to show a notification."),
		btn,
	))
	w.ShowAndRun()
}

Fyne version

2.4.5

Go compiler version

go1.21.5 darwin/amd64

Operating system and version

MacOS Sonoma 14.5 (Intel)

Additional Information

No response

@Gys Gys added the unverified A bug that has been reported but not verified label Jun 25, 2024
@andydotxyz
Copy link
Member

Sadly this is due to Apples enforcement policies. We cannot show a native notification unless the app has been packaged and run through the app launcher.

It will follow the standard process of shipped via the store or a package, or installed using "fyne install".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants