swiftDialog allows you to send system notifications using the --notification argument. This indicates that swiftDialog should send a system notification instead of showing a dialog window.
Notifications use the same --title, --message and --icon arguments to present text and media. Any other arguments not listed on this page are ignored.
There is an additional argument --subtitle which adds a subtitle to the notification.
From v3.1, swiftDialog routes notifications through dedicated helper applications embedded inside Dialog.app. Use the --style argument to select the notification type:
--style value
Behaviour
Helper used
banner
Notification appears briefly then dismisses automatically
Dialog Banner
alert
Notification persists until the user dismisses it
Dialog Alert
The default when --style is omitted depends on the system notification settings configured for the app.
Calling --notificationwithout--style still works for backwards compatibility but routes through the main Dialog.app bundle. This path is deprecated and will emit a warning to stderr:
In a future release, sending a notification without --style will default to --style banner.
To ensure the style types are correctly set, deploy a mobileconfig that pre-approves notifications for the relevant helper apps (au.csiro.dialog.banner and au.csiro.dialog.alert) with the desired notification style.
dialog--notification--stylebanner--title"Test Notification"--message"A test notification message"
Sending a persistent alert notification:
Terminal window
dialog--notification--stylealert--title"Test Notification"--message"A test notification message"
If the message is longer than what the notification can show, the message will be truncated and show elipses ... to indicate as such. There should also appear a chevron in the top right of the notification when the user hovers over the notification that lets the user expand the contents
Adding a subtitle:
Terminal window
dialog--notification--stylebanner--title"Test Notification"--message"A test notification message"--subtitle"Test Subtitle"
Including title and subtitle a notification can have up to 5 lines of text. A \n character within the message body will create a newline in the notification.
An image can be added with --icon and accepts all existing image formats and sources.
When displaying an image, the content of the notification can be expanded by the user
Note: You cannot replace the default icon that is displayed with the notification. Images added using --icon will appear within the notification
When you first use notifications you may not receive any feedback or be prompted to allow notifications.
To manually allow notifications you will need to go to System Settings -> Notifications and enable notifications for the relevant application(s). You can also select between None, Banner or Alert style.
When deploying swiftDialog via MDM it is preferred to deploy a mobileconfig that will pre-approve notifications and set the notification type.
If you have a mixed installation you can include multiple bundle entries in the same profile. An example payload for banner style notifications might look like this:
Notifications are not available: Couldn't communicate with a helper application
verify that the relevant Dialog application has notifications enabled in System Settings, either by applying one of the above mobileconfig files via MDM or manually in System Settings.
Notifications will use the default swiftDialog icon. If you would like to re-brand to use a different icon, e.g. a corporate identity, then you can use the following steps to update the app bundle icon to something more appropriate for your use.
Copy your replacement icon image to /Library/Application Support/Dialog/Dialog.png (case sensitive)
Install swiftDialog from the .pkg installer.
With the replacement Dialog.png in place the installer will replace the built in icon with the specified image. Notifications will then use the custom image as the notification icon.