pr8x / DesktopNotifications

A cross-platform C# library for native desktop "toast" notifications.
MIT License
177 stars 29 forks source link

OSX notifications #5

Open derekantrican opened 3 years ago

derekantrican commented 3 years ago

According to the readme, looks like this doesn't support OSX. Adding this issue as a tracking issue for that support

TheVeryStarlk commented 1 year ago

Have you thought of using commands? Like this osascript -e 'display notification "hello world!"'

cricketthomas commented 10 months ago

i have an intel mac with osx monterey, which i think will be new enough (its out of support now but its on 12.7.1). Do you have any guidance on contributing? I guess all i would need to do is open that xcode proj and update the api?

pr8x commented 10 months ago

@cricketthomas Hey, my initial plan was to just create a slim wrapper around the native UNUserNotificationCenter API and call it via P/Invoke. The main concern would be how to handle the app bundle registration. IIRC in order to send notifications on IOS/OSX your app needs to be registered somehow.

We could check out other projects like Juce or Unreal Engine. They seems to have the local notifications on OSX figured out.

cricketthomas commented 10 months ago

@cricketthomas Hey, my initial plan was to just create a slim wrapper around the native UNUserNotificationCenter API and call it via P/Invoke. The main concern would be how to handle the app bundle registration. IIRC in order to send notifications on IOS/OSX your app needs to be registered somehow.

We could check out other projects like Juce or Unreal Engine. They seems to have the local notifications on OSX figured out.

Wouldn't registering it just be done in the Entitlements.plist (i am not super familiar either)? https://docs.avaloniaui.net/docs/distribution-publishing/macos MAUI has something similar https://learn.microsoft.com/en-us/dotnet/maui/ios/entitlements?view=net-maui-8.0&tabs=vs

pr8x commented 10 months ago

@cricketthomas Ah I see. I wonder if this could be done from code? Would love this library to be "plug-and-play" without having to go through extra build steps. But if it's unavoidable it's also OK.

campos02 commented 2 months ago

I managed to include local notifications into an Avalonia app I'm working on using the new API. Couldn't get the delegate part to work, so no activation or button press events, but showing them works fine and I'm sure things like scheduling can be coded too.

It's all a couple Objective-C functions which I used P/Invoke to call. As for getting them to work I just had to create an app bundle doing like the documentation says, what's a bummer is you need to sign that bundle, otherwise the OS won't even show the notifications permission banner and will deny them instantly.

Not a complete support but could be useful for this project.