Displaying Notifications
Notification Center offers another opportunity for providing feedback during script execution. Use the Standard Additions scripting addition’s display notification
command to show notifications, such as status updates as files are processed. Notifications are shown as alerts or banners, depending on the user’s settings in System Preferences > Notifications. See Figure 24-1 and Figure 24-2.
To show a notification, provide the display notification
command with a string to display. Optionally, provide values for the with title
, subtitle
, and sound name
parameters to provide additional information and an audible alert when the notification appears, as shown in Listing 24-1 and Listing 24-2.
APPLESCRIPT
display notification "All graphics have been converted." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"
JAVASCRIPT
var app = Application.currentApplication()
app.includeStandardAdditions = true
app.displayNotification("All graphics have been converted.", {
withTitle: "My Graphic Processing Script",
subtitle: "Processing is complete.",
soundName: "Frog"
})
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-06-13