mjolnir._asm.ui.notification

Home: https://github.com/asmagill/mjolnir_asm.ui

Apple's built-in notifications system.

This module is based in part on code from the previous incarnation of Mjolnir by Steven Degutis.

activationType

mjolnir._asm.ui.notification.activationType[]

Convenience array of the possible activation types for a notification, and their reverse for reference.

    None                        The user has not interacted with the notification.
    ContentsClicked             User clicked on notification
    ActionButtonClicked         User clicked on Action button
    Replied                     User used Reply button (10.9) (not implemented yet)
    AdditionalActionClicked     Additional Action selected (10.10) (not implemented yet)

defaultNotificationSound

mjolnir._asm.ui.notification.defaultNotificationSound

The string representation of the default notification sound. Set soundName attribute to this if you want to use the default sound.

new

mjolnir._asm.ui.notification.new([fn,][attributes]) -> notification

Returns a new notification object with the assigned callback function after applying the attributes specified in the attributes argument. The attribute table can contain one or key-value pairs where the key corrosponds to the short name of a notification attribute function. The callback function receives as it's argument the notification object. Note that a notification without an empty title will not be delivered.

register

mjolnir._asm.ui.notification.register(tag, fn) -> id

Registers a function to be called when an Apple notification with the given tag is clicked.

registry

mjolnir._asm.ui.notification.registry[]

This table contains the list of registered tags and their functions. It should not be modified directly, but instead by the mjolnir._asm.notify.register(tag, fn) and mjolnir._asm.notify.unregister(id) functions.

show

mjolnir._asm.ui.notification.show(title, subtitle, information, tag) -> notfication

Convienence function to mimic Hydra's notify.show. Shows an Apple notification. Tag is a unique string that identifies this notification; any functions registered for the given tag will be called if the notification is clicked. None of the strings are optional, though they may each be blank.

unregister

mjolnir._asm.ui.notification.unregister(id)

Unregisters a function to no longer be called when an Apple notification with the given tag is clicked. Note that this uses the id returned by mjolnir._asm.ui.register.

unregisterall

mjolnir._asm.ui.notification.unregisterall()

Unregisters all functions registered for notification-clicks; called automatically when user config reloads.

withdraw_all

mjolnir._asm.ui.notification.withdraw_all()

Withdraw all posted notifications for Mjolnir. Note that this will withdraw all notifications for Mjolnir, including those not sent by us or that linger from previous loads of Mjolnir.

actionButtonTitle

mjolnir._asm.ui.notification:actionButtonTitle([string]) -> string

If a string argument is provided, first set the notification's action button title to that value. Returns current value for notification action button title.

activationType

mjolnir._asm.ui.notification:activationType() -> int

Returns whether the notification was generated by a push notification (remotely). Currently unused, but perhaps not forever.

actualDeliveryDate

mjolnir._asm.ui.notification:actualDeliveryDate() -> int

Returns the delivery date of the notification in seconds since 1970-01-01 00:00:00 +0000 (e.g. os.time()).

alwaysPresent

mjolnir._asm.ui.notification:alwaysPresent([bool]) -> bool

If a boolean argument is provided, determines whether or not the notification should be presented, even if the Notification Center's normal decision would be not to. This does not affect the return value of the presented attribute -- that will still reflect the decision of the Notification Center. Returns the current status. Defaults to true.

autoWithdraw

mjolnir._asm.ui.notification:autoWithdraw([bool]) -> bool

If a boolean argument is provided, sets whether or not a notification should be automatically withdrawn once activated. Returns the current status. Defaults to true.

delivered

mjolnir._asm.ui.notification:delivered() -> bool

Returns whether the notification has been delivered to the Notification Center.

hasActionButton

mjolnir._asm.ui.notification:hasActionButton([bool]) -> bool

If a boolean argument is provided, first set whether or not the notification has an action button. Returns current presence of notification action button. Defaults to true.

informativeText

mjolnir._asm.ui.notification:informativeText([string]) -> string

If a string argument is provided, first set the notification's informativeText to that value. Returns current value for notification informativeText.

otherButtonTitle

mjolnir._asm.ui.notification:otherButtonTitle([string]) -> string

If a string argument is provided, first set the notification's cancel button's title to that value. Returns current value for notification cancel button title.

presented

mjolnir._asm.ui.notification:presented() -> bool

Returns whether the notification was presented by the decision of the Notification Center. Under certain conditions (most notably if you're currently active in the application which sent the notification), the Notification Center can decide not to present a notification. This flag represents that decision.

release

mjolnir._asm.ui.notification:release() -> self

Disables the callback function for a notification. Is also invoked during garbage collection (or a mjolnir.reload()).

remote

mjolnir._asm.ui.notification:remote() -> bool

Returns whether the notification was generated by a push notification (remotely). Currently unused, but perhaps not forever.

send

mjolnir._asm.ui.notification:send() -> self

Delivers the notification to the Notification Center. If a notification has been modified, then this will resend it, setting the delivered status again. You can invoke this multiple times if you wish to repeat the same notification.

soundName

mjolnir._asm.ui.notification:soundName([string]) -> string

If a string argument is provided, first set the notification's delivery sound to that value. Returns current value for notification delivery sound. If it's nil, no sound will be played. Defaults to nil.

subtitle

mjolnir._asm.ui.notification:subtitle([string]) -> string

If a string argument is provided, first set the notification's subtitle to that value. Returns current value for notification subtitle.

title

mjolnir._asm.ui.notification:title([string]) -> string

If a string argument is provided, first set the notification's title to that value. Returns current value for notification title. Can be blank, but not nil. Defaults to "Notification".

withdraw

mjolnir._asm.ui.notification:withdraw() -> self

Withdraws a delivered notification from the Notification Center. Note that if you modify a delivered note, even with release, then it is no longer considered delivered and this method will do nothing. If you want to fully remove a notification, invoke this method and then invoke release, not the other way around.