Skip to content

Instantly share code, notes, and snippets.

@songgao
Created July 27, 2012 02:36
Show Gist options
  • Save songgao/3185894 to your computer and use it in GitHub Desktop.
Save songgao/3185894 to your computer and use it in GitHub Desktop.
How to enable Gmail notification for Safari 6 in Mountain Lion

How to enable Gmail notification for Safari 6 in Mountain Lion

If you're like me who uses Safari, and finds Gmail in browser most comfortable to use, you might want to enable notification from Gmail in Safari 6. Notification Center in Mountain Lion does support websites in Safari to send notifications, but by now Gmail does not ask for permission to send notifications. Fortunately Gmail uses html5 notification, which is supported in Safari 6. We can manually request permission from Safari for Gmail.

  1. Enable Develop menu. Safari->Preferences->Advanced: Check "Show Develop menu in menu bar".
  2. Open mail.google.com.
  3. Develop->Show Web Inspector. The console will show at bottom. Paste in following command in the console and press Enter. [1] window.webkitNotifications.requestPermission(function(){alert(window.webkitNotifications.checkPermission());})
  4. If the alert box shows 0, it means mail.google.com successfully gets notification permission. Send yourself an email with a different email address to test.

Reference

[1] Code stole from http://dangercove.github.com/html5-notifications/

@vrybas
Copy link

vrybas commented Aug 12, 2012

That's nice. But there's other problem still remaining. Notification stays for few seconds and then go away both from upper right corner, which is OK, and from the Notification Center, which is sad. So when you disable notifications, you're not going to see them stored in the notification panel for later review.

The same with Google Chrome. But there's a plugin "Checker Plus for Gmail" (https://chrome.google.com/webstore/detail/oeopbcgkkoapgobdbedcemjljbihmemj) which solves the problem. It uses Desktop Notifications as well, so they appear in Notification Center, but you can also set "Close After" option to "Never" and have them in Notification Center till you click or delete them. It's not affecting the upper right popup banner though, so it's gone in a few seconds as it should be.

So, is there any default timeout in webkitNotifications, which you can set, or any other workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment