Hello everyone :slightly_smiling_face: I am very h...
# feed
a
Hello everyone ๐Ÿ™‚ I am very happy to be able to announce a project i have been working on and polishing for a whille now while working at connect2x. Sysnotify is a Kotlin Multiplatform library which provides a common API and platform extensions for accessing local OS user notification APIs in Kotlin. The library currently has support for Windows (via a hand-rolled COM adaptor to avoid shell wrappers), macOS, Linux (via libnotify), Android, iOS and the Web via Kotlin/JS. I am happy to finally share this with you and of course, any feedback is welcome! Just keep in mind that there's still some things that are missing or not optimal, but you can take a look at the feature support matrix in the project README for that ๐Ÿ™‚
๐Ÿ”ฅ 11
t
This seems amazing! Really cool! How it handle the notification channel on Android? It just creates a default one and always use it?
๐Ÿ™Œ 1
a
On any platform you can create as many NotificationHandlers as you like, each one can have its own ID. On Android, that maps to unique NotificationChannels :)
s
@Alexander Hinze The lib is not on Maven Central. Did you publish it anywhere?
b
@Stefan Oltmann https://gitlab.com/connect2x/sysnotify/-/packages/43953498
Copy code
maven("<https://gitlab.com/api/v4/projects/58749664/packages/maven>")
implementation("de.connect2x:sysnotify:2.0.3")
thank you color 1
s
Unfortunately it does not work on macOS when running via
gradle run
inside IDEA. Looks like it may need additional configuration.
Copy code
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleProxyForCurrentProcess is nil: mainBundle.bundleURL file:///Library/Java/JavaVirtualMachines/zulu-24.jdk/Contents/Home/bin/'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018876bae0 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x000000018822eb90 objc_exception_throw + 88
	2   Foundation                          0x0000000189d7ba78 -[NSCalendarDate initWithCoder:] + 0
b
As far as I remember mac only works when distributed, because of API limitiations. That's why we enabled debug mode for non distributables, which disables notifications on macOS.
๐Ÿ’ก 1
s
Ah, I see. If I run my CMP app with
runReleaseDistributable
it does not crash immidiately. This brings up a system dialog:
Copy code
notificationHandler.requestPermissions {
            println("Requested: $it")
        }
But unfortunately this doesn't have any effect:
Copy code
notificationHandler.push(
    notification = Notification(
        title = title,
        description = message,
        dismissible = true
    ),
    tag = "tag???"
)
It's a bit unfortunate that it crashes so hard. I can't even wrap the creation into a try-catch-Block, so that it just silently fails for macOS dev version.
b
Yeah @Alexander Hinze tried really hard but did not found any way to circumvent it.
๐Ÿ‘€ 1
a
I recently introduced a debug flag when creating the notification handler which allows circumventing this issue in dev builds. But i'm still looking to find a neater solution for this.
๐Ÿ‘€ 1
s
Did you document that somewhere?
a
Yes, the KDoc for the NotificationHandler API mentions it, and there's a note in the macOS readme section
s
On Windows after registering sysnotify my app doesn't have a task bar icon anymore (it's the Duke again). Is that a known issue?