service-workerweb-pushpush-apiweb-notifications

service worker showNotification require interaction flag


the below code generates a notification which automatically goes away in 20 secs on chrome .. I don't get why this is happening ...!!! the document says that default timeout value of notification is 8 secs , then why it takes 20 secs to dismiss the notif,,,

and i know the require_interaction flag is not stable but ...do any of you have any idea as to if it works with only a specific chrome version etc ...!

self.registration.showNotification(title, {
        body: body,
        icon: icon,
        tag: tag,
        data: notificationData,
        vibrate: vibrate,
        requireInteration:'true'

Update the issue was requireInteraction flag spelling .. ..my bad ...!!


Solution

  • The timeout in the implementation is indeed 20 seconds so the documentation should probably be fixed.

    https://code.google.com/p/chromium/codesearch#chromium/src/ui/message_center/message_center_style.cc&cl=GROK&l=60&rcl=1452142029

    require interaction should be stable already. It shipped in M47 which is the stable version as far as I know.

    http://blog.chromium.org/2015/10/chrome-47-beta-idle-time-work-splash.html

    Also note that the flag is called requireInteraction (with a C) the msdn doc seems wrong there as well.

    Edit: Note that as chrome moves to native (OS provided) notifications the timeout is now defined by the underlying OS. For example in MacOS is 5 seconds. Different versions of linux and Windows 10 (once Chrome switches to native notifications in that platform) will be different as well.