subscribeNotification

abstract fun subscribeNotification(event: String?, callback: (event: String, userInfo: ReadonlyRecord<String, Any?>, object: String) -> Unit): Double(source)

The ID of this subscription

Subscribes to native notifications of macOS, callback will be called with callback(event, userInfo) when the corresponding event happens. The userInfo is an Object that contains the user information dictionary sent along with the notification. The object is the sender of the notification, and only supports NSString values for now.

The id of the subscriber is returned, which can be used to unsubscribe the event.

Under the hood this API subscribes to NSDistributedNotificationCenter, example values of event are:

  • AppleInterfaceThemeChangedNotification

  • AppleAquaColorVariantChanged

  • AppleColorPreferencesChangedNotification

  • AppleShowScrollBarsSettingChanged

If event is null, the NSDistributedNotificationCenter doesn’t use it as criteria for delivery to the observer. See docs for more information.