Beispiel #1
0
                categories = self.nc.notificationCategories
                category_id = str(uuid.uuid4())
                new_categories = categories.setByAddingObject(
                    UNNotificationCategory.categoryWithIdentifier(
                        category_id,
                        actions=actions,
                        intentIdentifiers=[],
                        options=UNNotificationCategoryOptionNone,
                    ))
                self.nc.notificationCategories = new_categories
                self._notification_categories[button_names] = category_id

                return category_id

    if UNUserNotificationCenter.currentNotificationCenter():
        Impl = CocoaNotificationCenter

elif Version(macos_version) < Version("11.1.0"):

    NSUserNotification = ObjCClass("NSUserNotification")
    NSUserNotificationCenter = ObjCClass("NSUserNotificationCenter")
    NSDate = ObjCClass("NSDate")

    NSUserNotificationActivationTypeContentsClicked = 1
    NSUserNotificationActivationTypeActionButtonClicked = 2
    NSUserNotificationActivationTypeAdditionalActionClicked = 4

    class NotificationCenterDelegate(NSObject):  # type: ignore
        """Delegate to handle user interactions with notifications"""