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. FindLOCAL-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.
showRepeatingNotification(message: String, title: String, interval: float, tag: int, repeat_duration: int)
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.
repeating_interval
the notification will be fired in a loop until you cancelled it.
Pick a random message from the string array pool.
Doesn't work under a schedule.
Iterate through each instance of the string array pool and loop back after reaching max_index
instance.
Doesn't work under a schedule.
(IOS Only) 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. (iOS only)
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.
- check if notifications
is_inited
, it means that application requested permissions from user. - call
init
if app didn’t requested it yet. - catch signal
enabled
or check methodis_enabled
. It will returnfalse
if user didn’t grant you permission. - get device token (
get_device_token
) for push notifications or catch signaldevice_token_received
- send your device token to the server side.
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.