-1

I have a web app something like slack which is used for chatting and when user is offline then we send the notification that "you have a new message". The notification is html5 push notification, so it works when user has not opened web app.

I have recently created an executable app for people who chat all day. But problem is that when a new message is coming : notification coming from exe app and browser both.

So my question is : Can we find if web app and exe app both are active in one device? So that we can supress one of the notification. Does a pc have something like common id which we can access from javascript in browser and executable too?

Note :- I have information stored in server that web app is active and exe is active, i only need to find if they are from same device.

Thanks in advance. Please let me know your solution.

Ujjwal Kumar Gupta
  • 2,308
  • 1
  • 21
  • 32
  • You can do this by with [extension](https://stackoverflow.com/a/12057088/863110). Another approach is to detect if the user is loggedin both in app and web in the server. The cons is if it's not on the same machine.. – Mosh Feu Jan 10 '19 at 16:40
  • yep trying to find same machine is the main problem here. And i dont want to install any extension by users. Users wont like the complexity of app uses. – Ujjwal Kumar Gupta Jan 11 '19 at 04:03
  • The only way I know is via extension and for a good reason - You don't want to allow to a website to access to your apps.. – Mosh Feu Jan 11 '19 at 22:03

1 Answers1

0

After a lot of hit and trial with different solutions - I found a solution.

I am embedding a http server in the exe app which let me communicate with web app. In the web app, i have added a web worker, which will ping the exe app server every 10 sec. If response received means exe app is active, then i turn off the notification on server by calling api. This will also make sure when the exe app is quitted, web worker wont get any response means exe is not active, so it activates the notification.

Now another issue was that - after installing the app, user didn't open the web app and he is getting two notification still. For overcoming this - i open the web app url when the exe app starts for the first time and it detects the status and turn off the browser notification. In the same process - i also save the browserId (a unique guid to identify the browser ) to the exe app and whenever exe app starts, i call the api to turn off the notification for these browserId.

Hope this helps someone.

Ujjwal Kumar Gupta
  • 2,308
  • 1
  • 21
  • 32