desktop_notifier.macos
¶
UNUserNotificationCenter backend for macOS.
Introduced in macOS 10.14.
Cross-platform with iOS and iPadOS.
Only available from signed app bundles if called from the main executable or from a signed Python framework (for example from python.org).
Requires a running CFRunLoop to invoke callbacks.
Module Contents¶
Classes¶
UNUserNotificationCenter backend for macOS |
- class desktop_notifier.macos.CocoaNotificationCenter(app_name='Python', notification_limit=None)[source]¶
Bases:
desktop_notifier.base.DesktopNotifierBase
UNUserNotificationCenter backend for macOS
Can be used with macOS Catalina and newer. Both app name and bundle identifier will be ignored. The notification center automatically uses the values provided by the app bundle.
- Parameters:
- async request_authorisation()[source]¶
Request authorisation to send user notifications. If this is called for the first time for an app, the call will only return once the user has granted or denied the request. Otherwise, the call will just return the current authorisation status without prompting the user.
- Returns:
Whether authorisation has been granted.
- Return type:
- async has_authorisation()[source]¶
Whether we have authorisation to send notifications.
- Return type:
- async _send(notification, notification_to_replace)[source]¶
Uses UNUserNotificationCenter to schedule a notification.
- Parameters:
notification (desktop_notifier.base.Notification) – Notification to send.
notification_to_replace (Optional[desktop_notifier.base.Notification]) – Notification to replace, if any.
- Return type:
- async _create_category_for_notification(notification)[source]¶
Registers a new notification category with UNNotificationCenter for the given notification or retrieves an existing one if it exists for our set of buttons.
- Parameters:
notification (desktop_notifier.base.Notification) – Notification instance.
- Returns:
The identifier of the existing or created notification category.
- Return type:
Optional[str]
- async _get_notification_categories()[source]¶
Returns the registered notification categories for this app / Python.
- Return type:
NSSet
- _clear_notification_categories()[source]¶
Clears all registered notification categories for this application.
- Return type:
None
- async _clear(notification)[source]¶
Removes a notifications from the notification center
- Parameters:
notification (desktop_notifier.base.Notification) – Notification to clear.
- Return type:
None