Here is my scenario:
- a client has opened a tab with my web app in it
- whenever there is an incoming connection I would like to notify him via Notifications API
- after clicking notification he should be redirected to this page / opened tab
- there he should see confirmation popup where he can decide if he wants to accept connection
I know how to do each part, but I do have problems with the correct order. I believe it has something to do with JS call stack. In the following code confirmation window is always first. Only after confirming it (or not) notification displays.
let n = new Notification("Incomming call");
let c = confirm('Do you accept?')
if(c) {
return this.peer;
}
How can I switch order? First notification, then confirmation prompt.