GithubHelp home page GithubHelp logo

alexgibson / notify.js Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 148.0 173 KB

A handy wrapper for the Web Notifications API

Home Page: https://alexgibson.github.io/notify.js/

License: Other

JavaScript 84.70% HTML 15.30%

notify.js's People

Contributors

alexgibson avatar bsawyer avatar chrisyip avatar fcsonline avatar garypendlebury avatar jbubriski avatar kitbrennan90 avatar maffoobristol avatar mdu avatar perrin4869 avatar qathom avatar superkarn avatar toddmotto avatar xosofox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notify.js's Issues

window.Notify.requestPermission throws error on IE11

Just updated to v1.2.8. Our application does not explicitly call Notify.isSupported() to check if the browser supports web notifications, as we relied on notify.js to do this for us in the past. However, after upgrading to notify.js 1.2.8, calling Notify.requestPermission calls through to window.Notification.requestPermission() which of course throws the error "cannot read property 'requestpermission' of undefined or null."

This may or may not be an issue, depending on where the responsibility lies for determining browser support. I wanted to raise this issue because I'm not sure this was intended behavior, I didn't see anything in the release notes about the responsibility shifting to the implementer of the library.
Any insight would be much appreciated.
Thanks,
-Erik

Not working with chrome mobile

Hello, you have built a fantastic little script.. well done.

I have found though, This does not work with chrome mobile which is a must. I have tested it with chrome desktop and works great.

Thanks again.
Ben

Picture

Good day
How do I display a picture or an icon on the notification?

jspm not found

I think it's unreasonable for a package to require the user to manually install something to be able to use your package.

Your package may depend on jspm if you want but I expect all package to be installable simply with a npm install.

For instance, all my packages (see this one for instance) are transpiled to ES5 before publishing.

Unsubscribe

Can you help with code to unsubscribe from notification

Weird export since 2.x

Hey,
I've updated to 2.0.2 and noticed that it exports differently.
I'm using Babel + CommonJS Module Plugin.
Since 2.0.2 I have to do the following:

import Notify from 'notifyjs';
if (Notify.default.needsPermission) {
  Notify.default.requestPermission();
}

Notice the default. - apparently it exports a Object that has a default member as default.

Add url parameter

Would it be possible to add url parameter, which should be opened whenever someone clicks the notification?
Right now it could be done via notifyClick event, but parameter should make it a little bit easier.

Support Promise API

The latest version of requestPermission deprecates the callback interface in favor of a Promise-based interface. This library should support the Promise-based interface as well.

It looks like Safari doesn't currently support the Promise interface, but it should be possible for this library to have its requestPermission both take a callback and return a promise for backwards compatibility.

ID

Is there a way to trigger something like "notifyClick" for a specific id ?

isSupported() is much less usable now

In my web app users have a checkbox if they want to receive desktop notifications yes or no. If their browser doesn't support notifications to begin with, I don't even want to show this checkbox. However, with the recent changes to isSupported(), I can't do this anymore because it just gives an error:

You must only call this before calling Notification.requestPermission(), otherwise this feature detect would trigger an actual notification!

So how am I supposed to check for support before asking my users if they want notifications?

Support mobile browsers through ServiceWorker

Trying the notification API on Android, I ran into the following:

http://stackoverflow.com/questions/29774836/failed-to-construct-notification-illegal-constructor

Not sure about iOS support. I was wondering, are there any plans to support mobile browsers through the ServiceWorkerRegistration.showNotification() API? Especially since the Notification API may be removed in future versions of desktop Chrome.
It seems to me that this library would be a great place to wrap all these different APIs and try to get a solution that works on most devices.

After downloading the repo , it is not working on chrome .

Hi ,

below is the website on which i have found your link
https://alxgbsn.co.uk/2013/02/20/notify-js-a-handy-wrapper-for-the-web-notifications-api/
testedwithonlinedemo

on the above mentioned webiste , when i tested with online demo . It works well on chrome , but then when i download the repo from github , It is not working on chrome.
clicking on notify button it should first shows allow/block notify popup and then after allowing it should start showing notifucation on chrome. Which is not happening.

Please check my attached screenshot , The popup which is coming only when you tested with online demo link , this is not coming after downloading the repo from github. And hence its not working on chrome

Errors in browser console

Hi Alex ,

Thanks for creating excellent notify.js library .
Unfortunately I am getting issues while trying to use this library sample example on my local machine .

notify.js:32 Uncaught SyntaxError: Unexpected token ...
notify.js:178 Uncaught SyntaxError: Unexpected token export

Also please find attached debug file, which got populated while installing dependencies & build file.

npm-debug.log.zip

Notify is not defined

it occures when write

var myNotification = new Notify('Yo dawg!', {
body: 'This is an awesome notification',
notifyShow: onNotifyShow
});

function onNotifyShow() {
console.log('notification was shown!');
}.
it will give notify not define error ("i am not using require here").

and if i use require like:

var Notify = require('notifyjs')
var myNotification = new Notify('Yo dawg!', {
body: 'This is an awesome notification',
notifyShow: onNotifyShow
});

function onNotifyShow() {
console.log('notification was shown!');
}.

then it shows
/Volumes/Project data/node/demo/node_modules/notifyjs/dist/notify.js:63
var N = window.Notification;
^
window is not defined.
please help

Tag the new updates

There seems to be a lot of nice updates since the last tag. Namely static isSupported() type functions. Any chance we can get a new tag soon so bower can pull this package in cleanly?

In any case great job on this package!

How could add link

Sorry I am new on front-end, I already embed as yours but I want to add link text to notify box. eg:
link .

Can I create notification which depends on the parameter?

Currently I see that I can create a static notification:

var myNotification = new Notify('Yo dawg!', {
  body: 'This is an awesome notification'
});

and then just invoke it with myNotification.show(). But is there a way to create a notification template and then pass parameters into it? Something like:

var myNotification = new Notify('New messages', {
    body: 'You have ' + num + ' new messages'
});

and then myNotification.show({num : 4})

Can't install latest version with Bower

I just tried to upgrade from v1.3.0 to the latest v2.0.2. But after running $ bower install, the installation directory no longer contains a notify.js file (or any other .js).

How to push notification via form

I want to push notification via input form for Title, Description and link ( Icon will always be static) - I post and retrieve data from/to xml file

`

Title


Description

`

The icon I want to use profile pic and upload it via a script file to set and adjust image so will always be showing profile pic

Then I just want to include a url to click to.

Can you assist or advice me

Thanx
Johan

Help Needed !

Hey !
I want a notification to popup on a particular day. As I will pack this into an app with electron and it will keep running in the background. Now I need a bit of assistance. The notification doesn't come until I reload the page. So If someone can help me with service worker kind of thing I will be really glad( I'm a noob). Please help me out.

This is the code so far
https://gist.github.com/leovarmak/f98a0ea24cb210c8189e86decffa06b5

You may need to request permission.

I got this error :

Permission has been granted by the user
index.html:42 Error showing notification. You may need to request permission.
O Google Chrome está atualizado
Versão 67.0.3396.99 (Versão oficial) 64 bits

expose Notify for CommonJS

I'm building with Grunt and not using ES6 includes with babel or webpack.

Would be handy for the lib to attach to window.Notify if possible

Cheers

Doesn't work in Chrome on Android

At least your demo page (http://alxgbsn.co.uk/notify.js/) displays notifications fine in desktop and mobile Firefox, as well as in desktop Chrome, but doesn't do anything neither in mobile Chrome, nor in Android default browser. I have tested it on:

  • Highscreen Alpha GT - Android 4.0.3, Chrome 30.0.1599.82
  • Digma iDxD10 - Android 4.0.4, Chrome 28.0.1500.94

(I don't know how to look up the default browser's version).
Please rectify, as I'm really looking forward to using your library. I'd be happy to provide assistance, if need be.

Timeout is not working when the page reloads

Hi everyone, i am having a little trouble with the timeout config. I set the timeout to 30s, but when i reload the page that notification doesnt close anymore.

var notification = new Notify('title', {body: 'message', timeout: 30});
notification.show();

Anyone knows how to fix that or just how to clear all Notifications (which i can use to clear when the page loads)!?

update to version 1.2.6 throws error in karma/PhantomJS

Hey guys,
I am having an issue with notify.js when running unittests out of karma/PhantomJS after updating to to notify.js v1.2.6:
ReferenceError: Can't find variable: Notification at /Users/beane/Code/debug-notify.js/bower_components/notify.js/notify.js:105

screen shot 2015-09-25 at 3 52 38 pm

This error is thrown before any of my tests run.
Here are my dependency versions:
"devDependencies": { "bower": "1.5.3", "jasmine-core": "2.3.4", "karma": "0.13.10", "karma-jasmine": "0.3.6", "karma-phantomjs-launcher": "0.2.1", "phantomjs": "1.9.18" }

Demo here: https://github.com/ErikBean/debug-notify.js

Any help with this would be great, as our dev team is stuck with the previous version until this gets resolved.
Thanks,
-Erik

All notifications are not working

I am so confused. Nothing has changed in my code but all of a sudden I cannot receive ANY notifications in chrome. None from any site.

Has anyone experienced this before? What is going on?

Click and show the tab Web container

How i can get the click for activate the tab with my Web application??

Is possible do that with your notify.js?

NOTE: Whatsapp has that behavior

Different behaviour between Firefox on Debian and Windows

Hi,

I have a strange behaviour with Notifications on Firefox. I use the version 45.0.1 both on Debian and Windows.

This code shows up the notification on Windows but not on Debian:

var Notify              = require("notifyjs");
var prepareNotification = function () {
    var timeoutNotification = new Notify("Inactivité détectée", {
        body: "Vous serez déconnecté pour cause d'inactivité dans 60 secondes.",
        closeOnClick: true,
        timeout: 5,
        icon: "http://domain.tld/example.png"
    });

    timeoutNotification.show();
};

if (!Notify.needsPermission) {
    prepareNotification();
} else if (Notify.needsPermission && Notify.isSupported()) {
    Notify.requestPermission(function () {
        prepareNotification();
    });
}

Your demo page works both on Windows and Debian: https://alexgibson.github.io/notify.js/

All is working fine with Chrome.

request for a notifyShow hide example

Thanks for a great library!

It would be very helpful to offer an example of hiding a notification after a few seconds.

My attempt to do


      var notification = new Notify(title, {
          body:  body,
          icon:  icon,
          notifyShow: function(){
            setTimeout(function(){
              console.log("notify cancel", notification);
              console.log("destroy result", notification.destroy());
            }, 1000);
          }
      });
      notification.showNotification();

does not hide the notification or cause an error. the code above logs:

notify cancel 
Notify {title: "Your Student Loan Rate is About to Go Up", options: Object, permission: null, onShowCallback: function, myNotify: Notification…}
destroy result undefined 

Also, I haven't figured out why calling showNotification works but show does not.

Thanks so much for any help you can offer!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.