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 · 5 comments
Open
2 tasks done

MacOS not asking for permission to show notifications #4974

Gys opened this issue Jun 25, 2024 · 5 comments
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".

@Gys
Copy link
Author

Gys commented Jul 4, 2024

Hmmm, fyne install does not support darwin? I tried the latest v2.4.5. Instead I used fyne release. If I install the app after that, a notification is shown, but only once. Even if I allow notifications.

@andydotxyz
Copy link
Member

Fyne install does support Darwin. It supports all the platforms we build for.

If for some reason you are not seeing follow-up notifications please open an issue, this is not a known problem.

@Gys
Copy link
Author

Gys commented Jul 4, 2024

Fyne install does support Darwin. It supports all the platforms we build for.

The install help says:

 OPTIONS:
   --target value, --os value    The mobile platform to target (android, android/arm, android/arm64, android/amd64, android/386, ios, iossimulator).
   --installDir value, -o value  A specific location to install to, rather than the OS default.
   --icon value                  The name of the application icon file.
   --use-raw-icon                Skip any OS-specific icon pre-processing (default: false)
   --appID value, --id value     For Android, darwin, iOS and Windows targets an appID in the form of a reversed domain name is required, for ios this must match a valid provisioning profile
   --release                     Enable installation in release mode (disable debug, etc). (default: false)
   --help, -h                    show help (default: false)

So it explicitly says only mobile platforms.

If I do fyne install --os darwin it says `Unsupported target operating system "darwin"'.

@andydotxyz
Copy link
Member

andydotxyz commented Jul 4, 2024

Yikes! Docs need updated. What it means is you can install to current OS or one of the mobile platforms.

Don't pass an os parameter and it will install on the current OS

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