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

Mac notifications do not work #132

Open
PfisterFactor opened this issue Jan 13, 2022 · 6 comments
Open

Mac notifications do not work #132

PfisterFactor opened this issue Jan 13, 2022 · 6 comments

Comments

@PfisterFactor
Copy link

PfisterFactor commented Jan 13, 2022

I tried running the example at https://github.com/hoodie/notify-rust/blob/main/examples/mac.rs.
However I get no notification, the program just runs and closes. The notification center doesn't have anything either.

I am running on a M1 Macbook Pro (14-inch, 2021) on MacOS Monterey.
Compiling with Rust 1.58.0 stable-aarch64-apple-darwin. stable-x86_64-apple-darwin produces the same results.

@PfisterFactor
Copy link
Author

PfisterFactor commented Jan 13, 2022

This seems to be an issue with mac-notification-sys, as I don't get a notification even when using that crate directly. I've posted an issue there: h4llow3En/mac-notification-sys#33 (comment)

@obelisk
Copy link

obelisk commented Dec 9, 2022

I know this issue is a bit old, but I investigated this last night and the problem is at least partially caused by where the binary is run from.

The daemon that handles notifications in macOS is called usernoted. When trying to generate notifications from my binary, usernoted threw errors about failing to read my binary (these errors show up in Console.app). I'm not sure why but my guess is because there is something it wants to check about the signature.

I develop in a subfolder of my documents which is a protected directory. Fetching the entitlements of usernoted:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>com.apple.coreduetd.allow</key>
        <true />
        <key>com.apple.coreduetd.context</key>
        <true />
        <key>com.apple.private.push-to-wake</key>
        <true />
        <key>com.apple.private.dark-wake-push</key>
        <true />
        <key>com.apple.duet.activityscheduler.allow</key>
        <true />
        <key>com.apple.private.aps-connection-initiate</key>
        <true />
        <key>com.apple.private.security.storage.Safari</key>
        <true />
        <key>com.apple.private.security.storage.HomeKit</key>
        <true />
        <key>com.apple.private.notificationcenter.server</key>
        <true />
        <key>com.apple.das.private.application.masquerade</key>
        <true />
        <key>com.apple.private.donotdisturb.state.updates.client-identifiers</key>
        <string>com.apple.private.nc.usernoted</string>
        <key>com.apple.private.donotdisturb.settings.modify.client-identifiers</key>
        <string>com.apple.private.ncprefs.dnd</string>
    </dict>
</plist>

None of which grant it permission to access my documents. So I tried running my binary from /tmp and notifications started being sent correctly. This should also extend to /usr/local/bin/ as that is also not a macOS protected directory (other than normal unix permission).

Hope this helps people in the future.

@Selyatin
Copy link

Once the binary is placed in the /Application directory it works just fine as well. This issue will cause problems only during development of software, since you'd have to move the binary to directories that usernoted has access to.

@milesj
Copy link

milesj commented Apr 27, 2023

What're the list of valid paths on macos then? This lib seems kind of useless if mac isn't easily supported.

@mitjans
Copy link

mitjans commented Jun 20, 2023

I can't reproduce the issue on an M2 mac. Using version v4.8.0.

@hoodie
Copy link
Owner

hoodie commented Jun 20, 2023

@mitjans that's why the issue is open for so long, it's a bit of a heisenbug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants