HTML5/Webkit Notification Gotchas

13 Nov

I just set out to create a notification hello world for the first time in about 6 months and came across several issues worth noting. ??These are the gotchas to be aware of:

* webkitNotifications.requestPermission() will only request permission if the function is called following a user action. (Similar to full-screening a video element, to avoid spamming and phishing.) If you try to automatically request during page load, it will have no effect.

* webkitNotifications.checkPermission() returns 0 if the app has permission and 1 if not. You would probably expect the return type to be boolean, not numeric, and moreover, you would expect the return value to be truthy if the app has permission.

* webkitNotifications.createNotification() creates an object; it doesn't actually show the notification. You need to show() the returned notification to do that.
Advertisements

One Response to “HTML5/Webkit Notification Gotchas”

  1. jerem November 13, 2010 at 9:08 pm #

    Another gotcha for me is the fact that notifications once showed don’t disappear until the user click on it. So if you want to use this API like Growl you must hide the notification yourself by using the .cancel() function with a setTimeout.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: