Godot module for local notifications (android and iOS)
This is a module for Godot Game Engine which add local and remote notification feature for iOS and Android.
At first you need NativeLib-CLI or NativeLib Addon.
Make nativelib -i local-notification
in your project directory if you are using CLI. Find LOCAL-NOTIFICATION
in plugins list and press "Install" button if you are using GUI Addon.
Enable Custom Build for using in Android.
Add wrapper scripts/localnotification.gd
into autoloading list in your project. So you can use it everywhere in your code.
Show notification with title
and message
after delay of interval
seconds with tag
. You can override notification by it's tag before it was fired.
If you defined repeating_interval
the notification will be fired in a loop until you cancelled it.
Show notification daily at specific hour and minute (in 24 hour format). You can overide the notification with new time, or cancel it with tag and register a new one.
Need help: Currently just support ios, need help on Android
Cancel previously created notification.
Cancel all pending notifications (implemented for iOS only).
Request permission for notifications (iOS only).
Check if notification permission was requested from user (iOS only).
Check if notification permission was granted by user (iOS only).
Request system token for push notifications.
Returns system token for push notification.
Returns custom data from activated notification (Android only).
Returns action from deeplink, if exists. (Android only).
Returns deeplink URI, if exists (Android only).
The default notification color is defined in android/build/res/values/notification-color.xml
. You can change it at your desire. The color string format is #RRGGBB
.
In order to change default notification icon you should make this new files:
android/build/res/mipmap/notification_icon.png Size 192x192
android/build/res/mipmap-hdpi-v4/notification_icon.png Size 72x72
android/build/res/mipmap-mdpi-v4/notification_icon.png Size 48x48
android/build/res/mipmap-xhdpi-v4/notification_icon.png Size 96x96
android/build/res/mipmap-xxhdpi-v4/notification_icon.png Size 144x144
android/build/res/mipmap-xxxhdpi-v4/notification_icon.png Size 192x192
Notification icons should be b/w with alpha channel. They will be tinted with color which we discuss above.
is_inited
, it means that application requested permissions from user.init
if app didn’t requested it yet.enabled
or check method is_enabled
. It will return false
if user didn’t grant you permission.get_device_token
) for push notifications or catch signal device_token_received
That’s all. Sending notifications processed by your server, receiving notifications processed by OS.
If the notification doesn't appear, make sure you're not trying to display it while your game is in the foreground. In iOS, apps can only show notifications if they are in the background. This implies that you must use interval
> 0.