Closed Bug 1230869 Opened 9 years ago Closed 8 years ago

Notification disapear too quickly

Categories

(Firefox :: General, defect)

41 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 862395

People

(Reporter: litianw, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36

Steps to reproduce:

1. Show a notification with code below:

  var options = {
      body: 'body text'
  }

  var theTitle = 'notification title';

  var n = new Notification(theTitle,options);
  // more examples here: https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API

2. Wait to see the notification come up


Actual results:

Notification window comes up and disappear within 3 seconds


Expected results:

Notification window stay there until user closes it manually
Hi Litianw,

After looking trough the documentation provided by you (https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API), found out the next thing:

"Firefox and Safari close notifications automatically after a few moments (around four seconds). This may also happen at the operating system level. Some browsers don't however, such as Chrome. To make sure that the notifications close in all browsers, at the end of the above functions, we call the Notification.close function inside a setTimeout() function to close the notification after 4 seconds. Also note the use of bind() to make sure the close() call is associated with the notification."

So you need to include in your script "setTimeout(n.close.bind(n), <time_value>);" function, in order to have it displayed longer.

Please try this and let me know if this information helped you.


Regards,
Paul
Flags: needinfo?(litianw)
Hi Paul,

Thanks for looking into this. I tried to add "setTimeout(n.close.bind(n), <time_value>);" function and set the time_value to 50s, but the notification still disappear very quickly (about 4 sec). Thanks.




(In reply to Paul Oiegas from comment #1)
> Hi Litianw,
> 
> After looking trough the documentation provided by you
> (https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/
> Using_the_Notifications_API), found out the next thing:
> 
> "Firefox and Safari close notifications automatically after a few moments
> (around four seconds). This may also happen at the operating system level.
> Some browsers don't however, such as Chrome. To make sure that the
> notifications close in all browsers, at the end of the above functions, we
> call the Notification.close function inside a setTimeout() function to close
> the notification after 4 seconds. Also note the use of bind() to make sure
> the close() call is associated with the notification."
> 
> So you need to include in your script "setTimeout(n.close.bind(n),
> <time_value>);" function, in order to have it displayed longer.
> 
> Please try this and let me know if this information helped you.
> 
> 
> Regards,
> Paul
Flags: needinfo?(litianw)
Hi Litianw,

Is there any chance you wrote something wrong ? This should work in theory. If you want to set a 50s  timeout, the function should look something like "setTimeout(n.close.bind(n), 50000);" . But you probably need to adapt this for your needs.

Also, you could provide the notification script you want to use as an attachment (short testcase) so we could try to reproduce the issue on our environment.
Flags: needinfo?(litianw)
I guess.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Component: Untriaged → General
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.