Code Monkey home page Code Monkey logo

push.js's Introduction



Build Status Coverage Status Known Vulnerabilities Maintainability

npm version npm Greenkeeper badge

Now a proud user of

Important Notice

Push is currently looking for co-maintainers of the repo. The guy who originally made this library, Tyler Nickerson, while still visiting this repo from time to time, is busy trying to work on his company Linguistic right now. As a result, he may not have time to answer everyone or fix bugs as quickly as they would like him too. If you find it pretty easy to find your way around this code and think you could help some people out, shoot me a message at [email protected] and let's talk.

What is Push?

Push is the fastest way to get up and running with Javascript desktop notifications. A fairly new addition to the official specification, the Notification API allows modern browsers such as Chrome, Safari, Firefox, and IE 9+ to push notifications to a user's desktop. Push acts as a cross-browser solution to this API, falling back to use older implementations if the user's browser does not support the new API.

You can quickly install Push via npm:

npm install push.js --save

Or, if you want something a little more lightweight, you can give Bower a try:

bower install push.js --save

Full Documentation

Full documentation for Push can be found at the project's new homepage https://pushjs.org. See you there!

Development

If you feel like this library is your jam and you want to contribute (or you think I'm an idiot who missed something), check out Push's neat contributing guidelines on how you can make your mark.

Credits

Push is based off the following work:

  1. HTML5-Desktop-Notifications by Tsvetan Tsvetkov
  2. notify.js by Alex Gibson

push.js's People

Contributors

basiclines avatar calinou avatar chriswiggins avatar elsangedy avatar greenkeeper[bot] avatar hbarcelos avatar joshbeckman avatar kokarn avatar mshick avatar n3il avatar natsukagami avatar nickersoft avatar onedevlad avatar overholt avatar sarbbottam avatar sugarshin avatar tagraf avatar thelufenk avatar vlazar avatar wx-ps 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  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

push.js's Issues

Feature Request add service worker options

It would be great if some of the additional option were added to the service worker showNotification constructor.

Particularly the Data option because that can be used in the service worker notification click, ie. to provide a URL for redirect.

Icon would be great too! :)

Possibility to detect first permission invocation

Hello guys,
Thanks for awesome library!
I have a feature request to show a dialog explaining what notifications will be sent to the user. I could not find similar example in the examples. Is there a way to know if permission popup is opened before calling Push.create?

Re-implement gulp as primary build tool

Gulp was removed a few commits ago and replaced by npm build scripts to simplify the build process. However, the list of npm scripts has become rather long and gulp should be used to remedy this. One issue that currently stands is the removal of the license comment in the minified version. Though technically fixable using NPM, Gulp can fix this using the gulp-uglify package and will require fewer dependencies overall.

No CDN?

I tried to use the github raw text, but it interpreted it as plain text, so i would appreciate a link to a cdn for my webpage.

notification.close "undefined"

Hey! Great plugin, but i found some issue.
I close a tab manually and when the notification timeout i have a "undefined" to the notification[id]. Becouse i close the notification, and that id still undefined in the array.

To bug fix i just add:

if (typeof(notification) === "undefined") {
return false;
}

At the function "closeNotification = function (id)".

Thanks :D

License not preserved in minified library

The current uglify implementation removes all comments, including the license and attributions at the top of the file. Investigate into fixing, either via command-line tools or the reinstallation of gulp (with the gulp-uglify package).

focus tab onclick

Can you wrap a function to focus on the tab when the user click on the notification?

Demo broken on Android

Noticed tonight after pushing the site redesign. Most likely broken for all of mobile. Will investigate.

notification is undefined

i receive this error in FF on Win 10 when i click the notification that pops up on the demo site: https://nickersoft.github.io/push.js/

TypeError: notification is undefined
Push/closeNotification()push.min.js:97
Push/createCallback/wrapper.close()push.min.js:245
Push/createCallback/<()push.min.js:252
1push.min.js:97:1

which is line 97 in the non-minified script:

if (notification.close) {

Bower: package does not actually contain source code

Bower support is in the works, and Push is currently registered with Bower, but an issue currently exists where running bower install push.js does not actually contain any source code. This is currently being fixed. I just thought I'd let people know before y'all start trying to install using Bower.

Also important: as part of the fix, gulp will be removed (for a second time).

IOS compatability

Has this library been tested or working on IOS chrome or safari? or does it work with any browser on ios?

NPM errors when installing devDependencies post-install

I've run into an issue when trying to install devDependencies after a regular NPM install. Here are the steps to reproduce:

  1. Run a simple npm install push.js
  2. cd into the push.js directory
  3. Run npm install again

It attempts to install the devDependencies, but finishes with the following output:

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.6
npm ERR! path /Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js/node_modules/.staging/push.js-05594a28
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js/node_modules/.staging/push.js-05594a28' -> '/Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js'
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js/node_modules/.staging/push.js-05594a28' -> '/Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.1.0
npm ERR! npm  v3.8.6
npm ERR! path npm-debug.log.2585175899
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.2585175899'
npm ERR! enoent ENOENT: no such file or directory, open 'npm-debug.log.2585175899'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/tjnickerson/Documents/Github/Nickersoft/push.js/test/node_modules/push.js/npm-debug.log

The contents of the push.js directory is then completely wiped. I've never encountered such behavior before while using NPM. Is anyone slightly more familiar with these kinds of errors and can perhaps provide some insight?

README not included in NPM package

I believe this is required for an up-to-date description on the NPM package page, so the README should be re-added to the distributed package.

SVG images not working

I just noticed that when I try to use an SVG image as the image for the push notification, nothing shows up.

Firefox Service Worker Support

Firefox does support service workers recently (46+), and it works as long as the browser is open (even if website tab is closed). But in code, service worker is only initialized for chrome and safari. that would be great to add firefox support as well

Count inconsistencies

It recently occurred to me that the count attribute of Push is writeable, and it shouldn't be. The count attribute should be wrapped inside a getter function. In addition, the count is never updated when a notification is closed via the close() wrapped method. These changes won't be hard, but they're extremely important. Will address ASAP.

Clarify platforms

The language in the description of this repo, on the site and in the readme seems to explicitly suggest that this works for desktop browsers only. But the Notifications API works on mobile browsers too. Is that intentional?

Good admin area example?

I cannot call this an issue, but wondering if you could point me to good tutorial on setting up (admin) area to actually push the messages?

Wanting to use this in school classroom but like to learn more about using first. Hate to have a kid call me out on it:)

Thanks in advance for your input.

Woody

How can we use the library for GCM push messages?

I'm looking for a way to integrate the library to allow GCM push notifications to be able to show messages on both desktop and mobile chrome browser.

Is it possible currently? If yes, how do I do it?

problem with webpack

Since the minified version contains Promise polyfill, it doesn't fit well with webpack (and I would tell browserify neither) :

import Push from "push.js"

The Push object contains Promise instead of Push constructor.
This can be fixed in the package.json : the main file should be push.js and not push.min.js which is the "standalone" version.

Potential bug with AMD support

Trying to run Push via Tonic results in the following error:

Tonic is a node environment, so window and other browser features won't exist. If you're just trying to access the global object, you can simply use global instead.

Not sure if similar errors exist in the real world. Has anyone used the library along with require.js or other AMD libraries? Will investigate this further.

TypeError: Cannot read property 'addEventListener' of undefined"

Hi, receiving this error on chrome mobile from the demo site.

08-22 01:07:33.115: I/chromium(32495): [INFO:CONSOLE(38)] "Uncaught (in promise) TypeError: Cannot read property 'addEventListener' of undefined", source: https://nickersoft.github.io/push.js/push.min.js (38)

I think it is because if it uses the service worker method, notification does not get defined.

its related to this issue #68

but i don't expect the events to work, those need to be done from within the service worker, for myself i just need it not to error getting the service worker loaded.

Customiezable service worker path

To support wider scenarios that would be great to make service worker path a parameter. So for example adding different channels for anonymous ad logged in user becomes possible.

timeout not enforced by Safari or Chrome

I am looking for a way to keep the notification on screen until the user interacts with it (onclick event or clicks close). Is there a way to accomplish that for Chrome and Safari? (Chrome more importantly)

I did try setting timeout: 0, but that did not do anything. Also tried timeout: 120000 and the notification is still cleared after a shorter time.

More robust Karma tests

Sometime in the future, I would like to add more Karma tests to tighten up the testing process. Some examples would be:

  • Testing the library works on AMD, CommonJS, etc.
  • Check for more instances in which function calls might return null
  • Testing certain conditionals work (e.g. the library defaults to using a ServiceWorker if the Notification constructor is not available)

Notification support for mobile devices

Great project!
However the description suggests support for all devices.
However it does not work on mobile devices. You do get the request the allow notifications, but a notification is never sent.
Is this support anticipated soon?

Meteor.JS install

How to install this on meteor.js? I tried the npm install and insert this inside my app

import moment from 'push.js'; const Push = require('push.js');

But the Push is still undefined..

Display page onClick

I'm sure this is very simple so apologies for the stupid question, but how does one simply display the page that triggered the notification when the user clicks on it? I see there's an onClick option to execute a some js, but I don't actually need to do anything except re-focus the browser and go to the appropriate tab. I don't need to execute any js on the page.

Thanks in advance.

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.