-
Notifications
You must be signed in to change notification settings - Fork 30
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
Switch to UN* API #10
Comments
As a heads up on why this might be a PITA...
|
Since macOS 11.0 the NSNotification Framework is now marked ad deprecated. |
@Pandawan FYI If you still have the time 🙂 |
Haven’t looked too much into it, but IIRC this only handles code signing and not notarization, which is required to run apps on Big Sur... Would have to check if that doesn’t prevent us from using the framework |
Alright, I started a I've been able to link the UserNotifications framework using However, my major roadblock and I'm unsure how to handle it is with using it. When I try getting an instance of the
Google searches return unanswered questions from a couple of years ago so that doesn't help. Also, it seems most people (and Apple docs) expect you to use Xcode to build your binaries, which limits the number of resources I can find on this. If anyone knows about the macos build steps, I'd appreciate any insight into what this might be caused by. |
FWIW, I have UserNotifications.framework working in cacao, but there's no demo - but if the app is codesigned with valid entitlements and so on, it should work. |
Nice, yeah something to try out. I see you implemented it in rust using the |
Pros are that it just feels more in-line with it being a Rust project. Cons... none so far, but for all I know there could be some. |
just checking in @Pandawan @h4llow3En are the roadblocks mentioned above still valid? are we stuck here or is there something we could pick up? |
Oh yeah sorry I never really got around to finishing this. Major roadblock was (probably still is) codesigning. It's possible but I have little to no knowledge of this and I can't find much documentation on doing it with non-Xcode codebases. So perhaps someone (with more experience) wants to take a stab at it? |
Unfortunately it's the same with me. I found https://github.com/indygreg/PyOxidizer/tree/main/tugger-apple-codesign which could be interesting, but I had no time to dive into it |
[Question]
It seems many libraries uses executable directly. So I wonder is there some reason to use raw objective-c in |
For osascript/Apple Script, the capabilities are much more limited (only title, subtitle, and sound are available). As for terminal-notifier, it doesn’t support actions and instead recommends using alerter instead for alerts (sticky notifications or notifications with actions). This would require having two binaries instead of one to support every kind of notification, which (imo) doesn’t feel very optimal when a simple objective-c file can handle both. In general, having Rust interface directly with the API is much more powerful than this kind of indirection. Perhaps we can integrate mac-notification-sys to use cacao (as mentioned above) since it already supports UserNotifications—or maybe take inspiration from how it does things? The other option, which is what I was trying to do a while ago, is to upgrade mac-notification-sys and figure out how to sign it. |
For what it's worth, the codesigning requirement does get a bit odd for people just looking to release a cross-platform tool. There's realistically an argument to just keep using the older API until it well and truly stops working. If you wanted to upgrade
|
I'm willing to have another go at this; however, I'm wondering if maybe we can release the current codebase as a new version on crates.io? There have been quite a few changes since the published version was released and I think some of these could be added to |
If you'd rather avoid linker flags, I made |
@h4llow3En I think we never made this release, if you want you can make me co-owner on crates.io and I can take that off your hands |
@hoodie I send an invite to be coowner |
I've been trying to get this going again for the past few days with a quick objc-only project and simply cannot get past this issue:
I've even tried with a Console project on Xcode directly and I get the same error. (To be fair, Xcode shows a lot of different options for linking, bundle, etc. so I'm not sure if I set things up properly on there). I thought that perhaps if I were to codesign, add the appropriate entitlements and Info.plist things would start working. However, this seems to get rejected by the OS (killed immediately on start) with the error (in the Console, not from the program directly):
implying that my push notifications entitlements are not complete but I cannot find any documentation on what the requirements for notification entitlements are. (Note: Adding/Removing sandbox does not change anything) Note that I've been codesigning with a self-signed certificate as I do not have a paid Apple Developer license. I've tried signing with one of the Xcode auto-generated ones (for development) in my Keychain Access but this does not seem to change anything. So any thoughts on how to get this working would be appreciated. |
The NS* API for notifications is deprecated, the new deal is this:
https://developer.apple.com/documentation/usernotifications
It also allows to add attachments, which might be interesting! A good example (and the most interesting class to play around with) is UNMutableNotificationContent.
I think a new API that supports badge, sound, and attachments would be nice. The old API could still be based on the deprecated macOS API (and be usable before mojave). IDK how to conditionally compile based on macOS version though.
The text was updated successfully, but these errors were encountered: