Is it possible to use Apple's Notification Center to display alerts using JavaScript?

Contributor ,
Feb 18, 2015

Copy link to clipboard

Copied

Hi all,

Is it possible to use Apple's Notification Center to display alerts using JavaScript?

Now I am using

alert("This is my Alert");

However, this displays a static alert that requires action from me.

For me it would be easier to make advantage of the Notification Center.

In Applescript it is something like this:

display notification "My Allert" with title "Alert Title"

TOPICS
Scripting

Views

127

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Is it possible to use Apple's Notification Center to display alerts using JavaScript?

Contributor ,
Feb 18, 2015

Copy link to clipboard

Copied

Hi all,

Is it possible to use Apple's Notification Center to display alerts using JavaScript?

Now I am using

alert("This is my Alert");

However, this displays a static alert that requires action from me.

For me it would be easier to make advantage of the Notification Center.

In Applescript it is something like this:

display notification "My Allert" with title "Alert Title"

TOPICS
Scripting

Views

128

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 18, 2015 0
Community Beginner ,
Jan 13, 2021

Copy link to clipboard

Copied

with the system command:

macNotification ("JavaScript", "Nur ein Test!", "Tink");

function macNotification (title, note, sound) {
	var appleScript = "'display notification \"" + note + 
	"\" with title \"" + title + "\" sound name \"" + sound + "\"'";
	app.system("osascript -e " + appleScript);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 13, 2021 0