notifications package

This package allows to post system notifications on Android and Windows.

Example:

from tatogalib.system.notifications import AppIcon

# importing tatogalib.system.notifications has created the member
# self.app.notifications which is the NotificationManager

print(f"Notifications enabled: {self.app.notifications.are_notifications_enabled()}")
id = self.app.notifications.post_notification("My title", text, AppIcon.INFO)

AppIcon class

class tatogalib.system.notifications.AppIcon
APP = 0
ERROR = 4
INFO = 1
QUESTION = 2
WARNING = 3

NotificationManager class

class tatogalib.system.notifications.NotificationManager(fnLog=None)

Creates a manager for handling system notifications.

On Android, the app needs the permission android.permission.POST_NOTIFICATIONS and the notifications must be enabled for the app in the Android settings.

Parameters:

fnLog (callable) – The callable which is called from the log method. It expects a string parameter

are_notifications_enabled()

Checks if notifications are enabled

Returns:

True when enabled, False otherwise

Return type:

boolean

cancel_all_notifications()

Cancel all previously shown notification

cancel_notification(id)

Cancel a previously shown notification

Parameters:

id (int) – The id of the notification

log(message)

Logs a message to the user code if fnLog was passed to the constructor

Parameters:

message (str) – The message to be logged

post_notification(title, message, icon=None)

Post and displays the notification and returns its id. The optional icon can be one of following 3 cases:

1. None will default to the app’s icon.
2. AppIcon is a system provided icon.
3. String with the path to an app-specific icon file,
e.g. self.app.paths.app / “resources” / “notification_icon.png”
Parameters:
  • title (str) – The title of the notification

  • message (str) – The message of the notification

  • icon (None or AppIcon or str) – The icon of the notification

Returns:

the id of the posted notification

Return type:

int

set_log(fnLog=None)

Sets a log method for debugging.

Parameters:

fnLog (callable) – The callable which is called from the log method. It expects a string parameter