Notification Scheduler Plugin allows scheduling of local notifications on the Android platform.
For iOS version, visit https://github.com/cengiz-pz/godot-ios-notification-scheduler-plugin .
Follow instructions on the following page to create a custom Android gradle build
Prior to using this plugin, a notification icon should be generated. For instructions please visit the following link:
There are 2 ways to install the Notification Scheduler
plugin into your project:
Steps:
Android Notification Scheduler
plugin in Godot EditorDownload
buttonChange Install Folder
setting pointing to your project's root directoryIgnore asset root
checkbox checkedInstall
buttonPlugins
tab of Project->Project Settings...
menu, in the Godot EditorSteps:
Plugins
tab of Project->Project Settings...
menu, in the Godot EditorCopy your notification icon to your project's android/build/res
directory.
Alternatively, you could use Android Studio
's Image Asset Studio
to generate your icon set.
Note: the notification icon resource should be of type drawable
Add a NotificationScheduler
node to your scene and follow the following steps:
NotificationScheduler
node
notification_opened
- when user taps notification itempermission_granted
permission_denied
NotificationScheduler
node to check that the application has permissions to post notifications:
$NotificationScheduler.has_post_notifications_permission()
NotificationScheduler
node:
$NotificationScheduler.request_post_notifications_permission()
permission_granted
signal will be emitted when the application receives the permissions
On Android, apps that target Android 13 or higher can ask for notification permission as many times as they want until the user explicitly denies the permission twice. If the user targets Android 12 or lower, the app can ask for permission as many times as it wants until the user denies the permission once. If the user denies the permission twice, the app can't ask again unless the user reinstalls the app
NotificationScheduler
node:(Best Practice: Don't promt users automatically, insted keep a button in settings to toggle notifications)
$NotificationScheduler.open_app_info_settings()
NotificationScheduler
node:
$NotificationScheduler.create_notification_channel(
NotificationChannel.new()
.set_id("my_channel_id")
.set_name("My Channel Name")
.set_description("My channel description")
.set_importance(NotificationChannel.Importance.DEFAULT))
NotificationData
object:
var my_notification_data = NotificationData.new()
my_notification_data.set_id(__notification_id).\
set_channel_id("my_channel_id").\
set_title("My Notification Title").\
set_content("My notification content").\
set_small_icon_name("ic_name_of_the_icon_that_you_generated").\
set_delay(my_delay_in_seconds)
NotificationScheduler
node:
$NotificationScheduler.schedule(
my_notification_data
)
NotificationData
's set_interval(interval_in_seconds)
method can be used for scheduling repeating notifications._NotificationData
's set_deeplink(data)
method can be used for delivering URI data along with the notification._
cancel(notification_id)
get_notification_id()
- alternative way to get the ID of the last opened notification.Android Build Template
is installed for the demo app.
demo/android/build/res/drawable-anydpi-v24/ic_demo_notification.xml
demo/android/build/res/drawable-hdpi/ic_demo_notification.png
demo/android/build/res/drawable-mdpi/ic_demo_notification.png
demo/android/build/res/drawable-xhdpi/ic_demo_notification.png
demo/android/build/res/drawable-xxhdpi/ic_demo_notification.png
adb logcat
is one of the best tools for troubleshooting unexpected behavior
$> adb logcat | grep 'godot'
on Linux
adb logcat *:W
to see warnings and errorsadb logcat *:E
to see only errorsadb logcat | grep 'godot|somethingElse'
to filter using more than one string at the same time#> adb.exe logcat | select-string "godot"
on powershell (Windows)Also check out: https://docs.godotengine.org/en/stable/tutorials/platform/android/android_plugin.html#troubleshooting
Developed by Cengiz
Original repository: Godot Android Notification Scheduler Plugin