{"id":17002130,"url":"https://github.com/sagiegurari/simple-web-notification","last_synced_at":"2025-05-05T03:43:44.372Z","repository":{"id":16292757,"uuid":"79667092","full_name":"sagiegurari/simple-web-notification","owner":"sagiegurari","description":"Web Notifications made easy","archived":false,"fork":false,"pushed_at":"2023-01-19T16:50:22.000Z","size":89,"stargazers_count":77,"open_issues_count":1,"forks_count":26,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-05T03:43:39.475Z","etag":null,"topics":["desktop-notifications","notification-api","notifications","web","web-notifications","webnotification"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagiegurari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-21T19:16:04.000Z","updated_at":"2024-11-21T12:58:19.000Z","dependencies_parsed_at":"2023-02-11T10:40:17.389Z","dependency_job_id":null,"html_url":"https://github.com/sagiegurari/simple-web-notification","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fsimple-web-notification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fsimple-web-notification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fsimple-web-notification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fsimple-web-notification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagiegurari","download_url":"https://codeload.github.com/sagiegurari/simple-web-notification/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252436240,"owners_count":21747467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["desktop-notifications","notification-api","notifications","web","web-notifications","webnotification"],"created_at":"2024-10-14T04:27:07.423Z","updated_at":"2025-05-05T03:43:44.355Z","avatar_url":"https://github.com/sagiegurari.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-web-notification\n\n[![NPM Version](http://img.shields.io/npm/v/simple-web-notification.svg?style=flat)](https://www.npmjs.org/package/simple-web-notification) [![CI](https://github.com/sagiegurari/simple-web-notification/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/simple-web-notification/actions) [![Coverage Status](https://coveralls.io/repos/sagiegurari/simple-web-notification/badge.svg)](https://coveralls.io/r/sagiegurari/simple-web-notification) [![Known Vulnerabilities](https://snyk.io/test/github/sagiegurari/simple-web-notification/badge.svg)](https://snyk.io/test/github/sagiegurari/simple-web-notification) [![Inline docs](http://inch-ci.org/github/sagiegurari/simple-web-notification.svg?branch=master)](http://inch-ci.org/github/sagiegurari/simple-web-notification) [![License](https://img.shields.io/npm/l/simple-web-notification.svg?style=flat)](https://github.com/sagiegurari/simple-web-notification/blob/master/LICENSE)\n\n\u003e Web Notifications made easy\n\n* [Overview](#overview)\n* [Demo](https://sagiegurari.github.io/simple-web-notification/)\n* [Usage](#usage)\n* [Installation](#installation)\n* [Limitations](#limitations)\n* [API Documentation](docs/api.md)\n* [Contributing](.github/CONTRIBUTING.md)\n* [Release History](#history)\n* [License](#license)\n\n\u003ca name=\"overview\"\u003e\u003c/a\u003e\n## Overview\nThe simple-web-notification is a simplified web notifications API with automatic permissions support.\n\nThis library requires no external dependencies, however the browser must support the Notification API or have a polyfill available.\n\nSee [W3 Specification](https://dvcs.w3.org/hg/notifications/raw-file/tip/Overview.html) for more information.\n\n## Demo\n[Live Demo](https://sagiegurari.github.io/simple-web-notification/)\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\nIn order to use the simplified web notification API you first must add the relevant dependencies:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"web-notification.js\"\u003e\u003c/script\u003e\n```\n\nNow you can use the API anywhere in your application, for example:\n\n```js\ndocument.querySelector('.some-button').addEventListener('click', function onClick() {\n    webNotification.showNotification('Example Notification', {\n        body: 'Notification Text...',\n        icon: 'my-icon.ico',\n        onClick: function onNotificationClicked() {\n            console.log('Notification clicked.');\n        },\n        autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)\n    }, function onShow(error, hide) {\n        if (error) {\n            window.alert('Unable to show notification: ' + error.message);\n        } else {\n            console.log('Notification Shown.');\n\n            setTimeout(function hideNotification() {\n                console.log('Hiding notification....');\n                hide(); //manually close the notification (you can skip this if you use the autoClose option)\n            }, 5000);\n        }\n    });\n});\n```\n\nIn case you wish to use service worker web notifications, you must provide the serviceWorkerRegistration in the options as follows:\n\n```js\nnavigator.serviceWorker.register('service-worker.js').then(function(registration) {\n    document.querySelector('.some-button').addEventListener('click', function onClick() {\n        webNotification.showNotification('Example Notification', {\n            serviceWorkerRegistration: registration,\n            body: 'Notification Text...',\n            icon: 'my-icon.ico',\n            actions: [\n                {\n                    action: 'Start',\n                    title: 'Start'\n                },\n                {\n                    action: 'Stop',\n                    title: 'Stop'\n                }\n            ],\n            autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)\n        }, function onShow(error, hide) {\n            if (error) {\n                window.alert('Unable to show notification: ' + error.message);\n            } else {\n                console.log('Notification Shown.');\n\n                setTimeout(function hideNotification() {\n                    console.log('Hiding notification....');\n                    hide(); //manually close the notification (you can skip this if you use the autoClose option)\n                }, 5000);\n            }\n        });\n    });\n});\n```\n\nIn case you wish to invoke the permissions API manually you can use the webNotification.requestPermission function.\u003cbr\u003e\nThis function triggers the request permissions dialog in case permissions were not already granted.\n\n```js\n//manually ask for notification permissions (invoked automatically if needed and allowRequest=true)\nwebNotification.requestPermission(function onRequest(granted) {\n    if (granted) {\n        console.log('Permission Granted.');\n    } else {\n        console.log('Permission Not Granted.');\n    }\n});\n```\n\nWhen using an AMD loader (such as RequireJS) or CommonJS type loader, the webNotification object is not automatically defined on the window scope.\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\nRun npm install in your project as follows:\n\n```sh\nnpm install --save simple-web-notification\n```\n\nOr if you are using bower, you can install it as follows:\n\n```sh\nbower install simple-web-notification --save\n```\n\n\u003ca name=\"limitations\"\u003e\u003c/a\u003e\n## Limitations\nThe web notifications API is not fully supported in all browsers.\n\nPlease see [supported browser versions](http://caniuse.com/#feat=notifications) for more information on the official spec support.\n\n## API Documentation\nSee full docs at: [API Docs](docs/api.md)\n\n## Contributing\nSee [contributing guide](.github/CONTRIBUTING.md)\n\n\u003ca name=\"history\"\u003e\u003c/a\u003e\n## Release History\n\n| Date        | Version | Description |\n| ----------- | ------- | ----------- |\n| 2020-05-13  | v2.0.1  | Revert bower.json deletion but not use it in CI build |\n| 2020-05-11  | v2.0.0  | Migrate to github actions, upgrade minimal node version and remove bower |\n| 2019-02-08  | v1.0.32 | Maintenance |\n| 2018-06-25  | v1.0.28 | Expose webNotification.requestPermission #5 |\n| 2018-06-14  | v1.0.26 | Better error detection on chrome mobile #4 |\n| 2017-08-25  | v1.0.21 | Support service worker web notifications |\n| 2017-01-31  | v1.0.3  | Removed polyfill dependency |\n| 2017-01-22  | v1.0.0  | Official release |\n| 2017-01-22  | v0.0.2  | Initial release |\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\nDeveloped by Sagie Gur-Ari and licensed under the Apache 2 open source license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fsimple-web-notification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagiegurari%2Fsimple-web-notification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fsimple-web-notification/lists"}