2016-06-20 10:42:06 +02:00
|
|
|
import Foundation
|
|
|
|
import objc
|
|
|
|
|
|
|
|
NSUserNotification = objc.lookUpClass('NSUserNotification')
|
|
|
|
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter')
|
|
|
|
|
2016-10-15 05:01:15 +02:00
|
|
|
|
2016-06-20 10:42:06 +02:00
|
|
|
def LBRYNotify(message):
|
|
|
|
notification = NSUserNotification.alloc().init()
|
|
|
|
notification.setTitle_("LBRY")
|
|
|
|
notification.setSubtitle_("")
|
|
|
|
notification.setInformativeText_(message)
|
|
|
|
notification.setUserInfo_({})
|
|
|
|
notification.setSoundName_("NSUserNotificationDefaultSoundName")
|
2016-12-01 00:05:01 +01:00
|
|
|
notification.setDeliveryDate_(
|
|
|
|
Foundation.NSDate.dateWithTimeInterval_sinceDate_(0, Foundation.NSDate.date()))
|
2016-06-20 10:42:06 +02:00
|
|
|
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
|
|
|
|
|
2016-10-15 05:01:15 +02:00
|
|
|
|
|
|
|
def notify(title, subtitle, info_text, delay=0, sound=False, userInfo=None):
|
|
|
|
userInfo = userInfo or {}
|
2016-06-20 10:42:06 +02:00
|
|
|
notification = NSUserNotification.alloc().init()
|
|
|
|
notification.setTitle_(title)
|
|
|
|
notification.setSubtitle_(subtitle)
|
|
|
|
notification.setInformativeText_(info_text)
|
|
|
|
notification.setUserInfo_(userInfo)
|
|
|
|
if sound:
|
|
|
|
notification.setSoundName_("NSUserNotificationDefaultSoundName")
|
2016-12-01 00:05:01 +01:00
|
|
|
notification.setDeliveryDate_(
|
|
|
|
Foundation.NSDate.dateWithTimeInterval_sinceDate_(delay, Foundation.NSDate.date()))
|
|
|
|
NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
|