Cross-platform notifications for libgdx.
Desktop support thanks to JCommunique and java-to-OS-notify.
This library needs libgdx starting from version 1.5.5.
Add the pretty bold parts into your build.gradle file:
repositories { maven { url "http://dl.bintray.com/spookygames/oss" } } ... project(":desktop") { ... dependencies { compile project(":core") ... compile "net.spookygames.gdx:gdx-notifications-desktop-jcommunique:0.0.1" for Swing notifications OR compile "net.spookygames.gdx:gdx-notifications-desktop-os:0.0.1" for native notifications } } project(":android") { ... dependencies { compile project(":core") ... compile "net.spookygames.gdx:gdx-notifications-android:0.0.1" } } project(":core") { ... dependencies { ... compile "net.spookygames.gdx:gdx-notifications:0.0.1" } }
We're talking platform-specific stuff here, so you'll need to initialize the magic in your specific initializers. Simply follow the indications from libgdx's wiki.
Classes you'll have for this:
DesktopNotificationHandler
(desktop, whether it's from JCommunique or java-to-OS-notify)AndroidNotificationHandler
(warning, notifications are not supported for android versions below 11)
And the base interface with two methods:
NotificationHandler
NotificationHandler handler = <your_platform-specific_handler_here>;
NotificationParameters parameters = new NotificationParameters();
parameters.id = 12;
parameters.title = "Notification for the people";
parameters.text = "Lorem ipsum";
handler.showNotification(parameters);
NotificationHandler handler = <your_platform-specific_handler_here>;
// You could (should!) very well get the parameters object from above
// But it will go nice too if you create a new object
// Only the id matters actually
NotificationParameters parameters = new NotificationParameters();
parameters.id = 12;
handler.hideNotification(parameters);
- Desktop (swing via JCommunique, native via java-to-OS-notify)
- Android
- iOS
- HTML