MacMost Now 749: Programming JavaScript To Send Safari 6 Notifications

With Safari 6 and Mountain Lion, users can get system notifications from web pages. Some simple JavaScript can be used for web developers to enable and use these notifications. You must first ask for permission to send notifications to the user, and then can trigger notifications. You can react to the user clicking on them as well. However, they only work while the web page is present.

Comments: 6 Responses to “MacMost Now 749: Programming JavaScript To Send Safari 6 Notifications”

    Richard Fuhr
    7 years ago

    Hi Gary, Thanks for providing this interesting example of using the new Notifications technology. It worked great on Safari 6 on my Mac running Mountain Lion. Is this kind of JavaScript also supposed to work (or work in some future release) of iOS on iPods, iPhones and iPads? Right now your sample web page did not seem to work on my iPhone.

      7 years ago

      I haven’t tested it, but perhaps in iOS 6? If not, I’m sure Apple will have it working at some point. Of course it doesn’t work with other browsers and on Windows, so there’s probably no rush.

    Doug
    7 years ago

    Is it possible to send notifications without first requesting permission? Only asking because it might be possible for a website to use notifications as a new form of pop-up for advertising purposesm which would get annoying.

      7 years ago

      No. You have to ask permission for a notification. Of course a web site could pop up a notification-looking graphic on its site. That’s been possible since the start of the web. But to get into the Mac’s notification center, permission has to be asked first, and you always have control over your list of allowed sites. So this won’t be used for ads.

    John Blake
    7 years ago

    I am trying to get my head around this feature. I work in a school. It is a challenge to communicate with middle school students. We make daily announcements, to remind students about up coming events, and procedures. The idea of notifications being pushed to their MacBooks or in some schools I am familiar with that have iPads, is interesting. I want to try this. We use Joomla and I am not sure the HTML script would work on that page. Hopefully, someone will try it. We are not running Mountain Lion on our MacBooks, and are not using iPads. It is still a cool idea and I can see the pluses of running it on a website in schools.

      7 years ago

      It wouldn’t work unless they are using Mountain Lion. Plus, this kind of notification only works if they happen to be looking at the web site at that time. For what you want, it would probably be best to figure out a way to send text messages to them. Those are like pure notifications. Text messages or emails.

Comments Closed.