Nativefier: Desktop Notifications

Created on 25 Jan 2016  路  34Comments  路  Source: jiahaog/nativefier

Heyo,

What's the effort involved in getting the desktop notifications API lined up to pass through toasts to the host OS?

Would love to finally replace the janky chrome hangouts app once and for all.

bug

Most helpful comment

Hello all,
I have created a fork which implements the --app-user-model-id flag to Nativefier. using @mentofa123 and @JiDoan solutions. I have also created the app ShorcutCreator.exe to create the shortcut with the AppUserModelId parameter. The only thing missing is integrating this exe with the nativefying process of an app.
The fork and more details can be found at: https://github.com/rdcvnh/nativefier

@mentofa123 and @JiDoan , I can add your names to the Credits section. Let me know if it's OK for you.

All 34 comments

Hi, what is the specific issue you're having with the notification? I believe clicking the notification will bring you back to the app if it is minimised?

I'm not getting any notifications whatsoever and assumed that meant they were unsupported, is that not the case? How are they supported currently?

Electron just supports them out of the box! If you're using facebook messenger you have to go into the messenger settings to turn on the desktop notifications.

Could you provide me with the following:

Version of Nativefier (run $ nativefier --version)
Version of Node.js (run $ node --version)
Command line parameters
OS and architecture you are running Nativefier from
Stack trace from the error message (if any)
Instructions to reproduce the issue

Same Problem, cant show notifications...
Example:

<script>
function notifyMe() {
  // Let's check if the browser supports notifications
  if (!("Notification" in window)) {
    alert("This browser does not support desktop notification");
  }

  // Let's check whether notification permissions have already been granted
  else if (Notification.permission === "granted") {
    // If it's okay let's create a notification
    var notification = new Notification("Hi there!");
  }

  // Otherwise, we need to ask the user for permission
  else if (Notification.permission !== 'denied') {
    Notification.requestPermission(function (permission) {
      // If the user accepts, let's create a notification
      if (permission === "granted") {
        var notification = new Notification("Hi there!");
      }
    });
  }

  // At last, if the user has denied notifications, and you
  // want to be respectful there is no need to bother them any more.
}Notification.requestPermission();function spawnNotification(theBody,theIcon,theTitle) {
  var options = {
      body: theBody,
      icon: theIcon
  }
  var n = new Notification(theTitle,options);
}
</script>
<button onclick="notifyMe()">Notify me!</button>

Same problem here. No desktop notifications (Inbox & Pivotal Tracker) and verified that they're turned on from within the app.

Are you sure you have the latest version of nativefier? I've tried to nativefy http://www.bennish.net/web-notifications.html, whatsapp web, facebook messenger and it appears to work. Could you check to see if this is specific to the site you are using?

Not Works ;(

Apparently it indicates that the notification was shown, but never did.

no_notifications

Same issue for me. I just installed nativefier 6.10.1 using npm 5.5.0 on latest Mac OS X El Capitan. I've got no notifications for http://hangouts.google.com.

I haven't tried other websites.

@felipead Could you try it on http://www.bennish.net/web-notifications.html

It appears to work for me on windows 10 and OSX11.2 as well...

Notifications are working for me on http://www.bennish.net/web-notifications.html

Currently trying to figure out why they aren't on Inbox or Pivotal.

UPDATE: Inbox still doesn't have notifications. Sometimes I struggle.

Not works on Windows 8 :(

Notifications are not working for "hangouts.google.com" but work for "http://www.bennish.net/web-notifications.html"

OS X El Capitan: 10.11.5
Nodejs: v5.4.0
Nativefier: 7.0.1
Architecture: x64
Electron v1.1.3

I realized I'm running an older version of Node so I completely reinstalled Node to get to v6.2.2.
Same results.

I hear the notification sound for the hangouts app, but there is no alert popup.

[edit]
It looks like it might be an issue with Hangouts not sending a desktop notification.
I was able to successfully trigger a notification by opening the dev-tools in the nativefier Hangouts app and running:

var notification = new Notification('Notification title', {
      icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
      body: "Hey there! You've been notified!",
    });

@tseven I don't really use Hangouts, does it send a notification if we access it from chrome directly? Or are there certain settings you have to turn on for the desktop notifications, I believe this is the case for messenger.com

Alternatively you can use https://github.com/yakyak/yakyak The same Electron build especially for hangouts.

I'm not getting notifications from gmail on windows 10, using 7.0.1

The http://www.bennish.net/web-notifications.html isn't showing notifications on Windows 8 for me when Nativefiering it. It says notification permission has been granted, but neither showing it immediately nor showing it after 5 seconds does anything. Works fine in Chrome.

EDIT: Discovered the following which reveals some interesting information about notifications from Electron in Windows 8/7. Maybe a workaround can be implemented? https://stackoverflow.com/questions/31606454/using-notification-api-for-electron-app

Works fine on Windows 10, though it does say "Electron" as the notification app that it comes from. Anyway that we can change this to the webpage's name?
2017-05-17 01 15 11

I'm having trouble with getting any kind of mentions working for Windows 10 on the https://www.bennish.net/web-notifications.html site. Could someone share his/her configuration, command line arguments, and any changes to Windows (if any)? Attached is my configuration.

Version of Nativefier: 7.5.4
Version of Node.js: v6.11.2
Command line parameters: nativefier https://www.bennish.net/web-notifications.html 
OS and architecture you are running Nativefier from: Windows 10
Stack trace from the error message (if any): None
Instructions to reproduce the issue: Build then try to trigger a notification

Exactly the same issue as @JiDoan on Windows 10 with nativefier 7.5.4 but works fine on Windows 7... :(

I figured out how to get notifications to work again on Windows 10 (Build 1709) thanks to the help in the electron repo. In a nutshell, you need to register you Nativefier "app" for notifications using the Windows API (sample code). Once you have your app registered, you need to add _electron.app.setAppUserModelId("<Your app name>"); in your resources\app\lib\main.js file and things will work.

Perhaps Nativefier can add a flag for Windows App ID so you don't have to edit the main.js file yourself?

Just tried on latest MacOSX with nativefier v7.6.1 - it doesn't allow to enable push notifications.
I used this page as an example: https://gauntface.github.io/simple-push-demo/

@JiDoan On windows 10, installing an app with Inno Setup got me there. In the setup script, just make sure the AppUserModelID matches what gets put in resources\app\lib\main.js. That worked like a charm for me. To boot, Inno Setup is free.

@jidoan i cant get this to work. Maybe you can describe what you did exactly ._.

Edit: it now works, thanks.
For everyone struggling with this issue:

  1. native any web app
  2. create a shortcut of the .exe file
  3. Edit in the details property of this shortcut the property "AppUserModelId". Use any name you wanna give. For example i used "nativefier." ( to see this property follow this link https://winaero.com/blog/how-to-show-more-details-for-shortcuts-in-windows-8-1-windows-8-and-windows-7/ )
  4. copy this shortcut to your startmenu ( C:\ProgramData\Microsoft\Windows\Start Menu\Programs)
  5. Add this line to your main.js _electron.app.setAppUserModelId(""); ( replace < your app name > with the name you set in step 3.
  6. Start the app.
  7. Profit?

Hello all,
I have created a fork which implements the --app-user-model-id flag to Nativefier. using @mentofa123 and @JiDoan solutions. I have also created the app ShorcutCreator.exe to create the shortcut with the AppUserModelId parameter. The only thing missing is integrating this exe with the nativefying process of an app.
The fork and more details can be found at: https://github.com/rdcvnh/nativefier

@mentofa123 and @JiDoan , I can add your names to the Credits section. Let me know if it's OK for you.

Sure I don't mind @rdcvnh, but I wouldn't have figured it out without @NicolasConstant's post in the electron repo.

@rdcvnh any plans to submit a pull request to the main repository?

@JacobDB I would like to first have the ShortcutCreator.exe integrated into the build process as described on my README.md (I haven't figured out how to do so). Otherwise I think it wouldn't make sense to submit a solution that still requires some manual work.

@rdcvnh Maybe this could be helpful to figure it out https://github.com/KochiyaOcean/windows-shortcuts

@pseudonymcp It seems promising. I will take a look at it. Thank you!

I got the notifications to work with @rdcvnh's method. I just want them to be able to persist and when the icon is in the system tray, have that notification open the app

is there a way to do that?

@artistro08 I will check on that. I think it should be doable.

@artistro08 maybe this PR #640?

Is this fix in the final release? I just created a Skype nativefier app and am getting no notifications. I tried the http://www.bennish.net/web-notifications.html app as well, it did show notifications being successfully generated but no Windows 10 banners popped up.

Hi all. Sorry, I haven't had much time to look into it. If someone is interested in picking up where I left an eventually submit a pull request as suggested, you're more than welcome:
https://github.com/rdcvnh/nativefier

The fork should be a bit outdated by now, but the additional code should be portable to the newer versions of nativefier.

Hopefully this will get resolved soon鈩笍 with #955. 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

citrusui picture citrusui  路  3Comments

Waitsnake picture Waitsnake  路  5Comments

raulcraveiro picture raulcraveiro  路  4Comments

vegbrasil picture vegbrasil  路  4Comments

shnbhg picture shnbhg  路  5Comments