AndroidNotificationPlugin is a Godot plugin for managing and sending notifications on Android devices.
- Download the
.zipfile of this repository. (Or just clone the repository) - Extract it into your project under
res://addons/.
The structure should look like this:
res://
└── addons/
└── AndroidNotificationPlugin/
├── plugin.cfg
├── export_plugin.gd
└── ...
- In Godot, go to Project → Project Settings → Plugins and activate AndroidNotificationPlugin.
- Add a
NotificationNodeto your scene. - Configure notification images:
- Load them as CompressedTexture2D.
- Assign a resource name for each image.
- Recommendation: set an
small_icon.pngfor simpler implementation.
- Define channels:
- At least one channel is required.
- Important: do not repeat channel IDs.
- Permission:
On devices running Android 13 (API 33) or higher, the POST_NOTIFICATIONS permission is required in order to display notifications. Call
NotificationNode.request_post_notification()to request this permission from the user at runtime.
After setup, the plugin will be ready to use. This section describes the main functions available for sending, scheduling, and managing notifications in your Godot Android project. Examples of usage can be found in the main.gd file included in the repository.
trigger_notification(channel: String, notification_data: Notification) -> StringParameters:
channel(String): The notification channel identifier.notification_data(Notification): Notification object.
json_notification(channel: String, json_name: String) -> StringParameters:
channel(String): The notification channel identifier.json_name(String): Name of the JSON file containing notification data.
schedule(channel: String, notification_data: Notification, past_n_seconds: int = 0) -> StringParameters:
channel(String): The notification channel identifier.notification_data(Notification): Notification object.past_n_seconds(int, optional): Delay in seconds before the notification is triggered (default is 0).
schedule_json(channel: String, json_name: String, past_n_seconds: int = 0) -> StringParameters:
channel(String): The notification channel identifier.json_name(String): Name of the JSON file containing notification data.past_n_seconds(int, optional): Delay in seconds before the notification is triggered (default is 0).
cancel(notification_id: int) -> StringParameters:
notification_id(int): The ID of the notification to cancel. If the notification has already been sent, it will be removed from the notification bar.
NotificationNodemethods return aString. This is a stringified object. If needed, you can parse it withNotificationResult.parse(res: String) -> NotificationResultCurrently, the available results are:NotificationCreated,NotificationCanceled, andNotificationError. This implementation is still basic, so the methods return aStringto let you handle it as you find most appropriate.- To save and modify JSONs use
JSONHandler.save_json(name: String, data: Dictionary = {}).
- Persistent scheduled notifications: ensure that scheduled notifications remain active even after the app is closed or restarted.
- Extended customization options: provide more ways to customize notifications.
This project is licensed under the MIT License.