html5 - Webkit notifications requestPermission function doesn't work -
i trying implement support webkit's native desktop notifications on site. when try ask user's permission use notifications, absolutely nothing happens. example, following html not prompt chrome ask me permission:
<html lang="en"> <head></head> <body> <h1>testing</h1> <script> window.webkitnotifications.requestpermission(); </script> </body> </html>
i know there no problem version of chrome because other sites (e.g. http://www.html5rocks.com/tutorials/notifications/quick/) work fine: can see both prompt , subsequent notifications.
check specification @ chromium api docs. can call feedback user gesture/action - mouse click etc.
requestpermission requests user agent ask user permission show notifications scripts. this method should called while handling user gesture; in other circumstances have no effect. method asynchronous. function provided in callback invoked when user has responded permission request. if current permission level permission_denied, user agent may take no action in response requestpermission.
update 2014-10-01: in chrome 37, the user gesture requirement removed. should possible request permission display notifications @ moment. if wish target older versions of chrome (eg. in corporate environment), you'll need continue relying on user gesture events.
Comments
Post a Comment