{"_id":"@alicenewberry/push-receiver","_rev":"2-4e65dbeec2211d30cae163b331f2d32a","name":"@alicenewberry/push-receiver","dist-tags":{"latest":"2.3.0"},"versions":{"2.1.1":{"name":"@alicenewberry/push-receiver","version":"2.1.1","description":"A module to subscribe to GCM/FCM and receive notifications within a node process.","main":"src/index.js","scripts":{"start":"node scripts/listen","register":"node scripts/register","send":"node scripts/send","pretty":"prettier-eslint --single-quote --trailing-comma es5 --write \"**/*.js\" \"**/*.json\"","pretty:check":"prettier-eslint --single-quote --trailing-comma es5 --list-different --log-level silent \"**/*.js\" \"**/*.json\"","lint":"eslint 'src/**/*.js'","lint:fix":"eslint 'src/**/*.js' --fix","test":"jest","precommit":"lint-staged"},"lint-staged":{"*.js":["eslint --fix","prettier-eslint --single-quote --trailing-comma es5 --write"],"*.json":["prettier-eslint --single-quote --trailing-comma es5 --write"]},"repository":{"type":"git","url":"git+ssh://git@github.com/alicenewberry/push-receiver.git"},"keywords":["push","service","fcm","gcm","notifications","node","electron","receiver"],"author":{"name":"alicenewberry"},"license":"MIT","bugs":{"url":"https://github.com/alicenewberry/push-receiver/issues"},"homepage":"https://github.com/alicenewberry/push-receiver#readme","devDependencies":{"babel-eslint":"^7.2.3","eslint":"^4.4.1","eslint-plugin-jest":"^20.0.3","http-proxy":"^1.16.2","husky":"^0.14.3","jest":"^22.2.2","lint-staged":"^6.1.0","prettier":"^1.6.1","prettier-eslint":"^7.0.0","prettier-eslint-cli":"^4.3.0","yargs":"^10.0.3"},"dependencies":{"http_ece":"^1.0.5","long":"^3.2.0","protobufjs":"^6.8.0","request":"^2.81.0","request-promise":"^4.2.1","uuid":"^3.1.0"},"_id":"@alicenewberry/push-receiver@2.1.1","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-8TwzFz82BzI22SL+ecDMlfxca6a6jVddiy9Wfz3ug1E0IC73si6TcUzTy6Cq5HPZm3lmezxLe48OSejw/d5BRw==","shasum":"f2c6686b6509829b39a4e44e64a80f1f6c0e42c5","tarball":"https://registry.npmjs.org/@alicenewberry/push-receiver/-/push-receiver-2.1.1.tgz","fileCount":25,"unpackedSize":56370,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEaD21QtboRhJmyi+xW/Z+7fEQ0Fe5FR1CWCdBhcxspFAiAggDIWhCVjCz/C5XoHHHv+/aAtqpxY9F4rXqK0oDMwlg=="}]},"_npmUser":{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"},"directories":{},"maintainers":[{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/push-receiver_2.1.1_1709058988437_0.26233938755144504"},"_hasShrinkwrap":false},"2.2.2":{"name":"@alicenewberry/push-receiver","version":"2.2.2","description":"A module to subscribe to GCM/FCM and receive notifications within a node process.","main":"src/index.js","scripts":{"start":"node scripts/listen","register":"node scripts/register","send":"node scripts/send","pretty":"prettier-eslint --single-quote --trailing-comma es5 --write \"**/*.js\" \"**/*.json\"","pretty:check":"prettier-eslint --single-quote --trailing-comma es5 --list-different --log-level silent \"**/*.js\" \"**/*.json\"","lint":"eslint 'src/**/*.js'","lint:fix":"eslint 'src/**/*.js' --fix","test":"jest","precommit":"lint-staged"},"lint-staged":{"*.js":["eslint --fix","prettier-eslint --single-quote --trailing-comma es5 --write"],"*.json":["prettier-eslint --single-quote --trailing-comma es5 --write"]},"repository":{"type":"git","url":"git+ssh://git@github.com/isaleoff/push-receiver.git"},"keywords":["push","service","fcm","gcm","notifications","node","electron","receiver"],"author":{"name":"alicenewberry"},"license":"MIT","bugs":{"url":"https://github.com/isaleoff/push-receiver/issues"},"homepage":"https://github.com/isaleoff/push-receiver#readme","devDependencies":{"babel-eslint":"^7.2.3","eslint":"^4.4.1","eslint-plugin-jest":"^20.0.3","http-proxy":"^1.16.2","husky":"^0.14.3","jest":"^22.2.2","lint-staged":"^6.1.0","prettier":"^1.6.1","prettier-eslint":"^7.0.0","prettier-eslint-cli":"^4.3.0","yargs":"^10.0.3"},"dependencies":{"http_ece":"^1.0.5","long":"^3.2.0","protobufjs":"^6.8.0","request":"^2.81.0","request-promise":"^4.2.1","uuid":"^3.1.0"},"_id":"@alicenewberry/push-receiver@2.2.2","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-AZfVJlWb3hRpJzsvvj8LLqS2il6a9KnaQK8d7nPTr7b2MsGtpQ5WE9KOAzI7WS72wRbalj9A/kjI+TedrqbCrw==","shasum":"a003f9a5a4e20691dcfa214f556407928340e138","tarball":"https://registry.npmjs.org/@alicenewberry/push-receiver/-/push-receiver-2.2.2.tgz","fileCount":25,"unpackedSize":56355,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGhA4uHZWtSfZn80/wtFoFG5osT/BpFZykujyhMscMngIhAMmwux8ZnjKxwJwYsh6qpHVCx2t26Y320/CLywJ88QSZ"}]},"_npmUser":{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"},"directories":{},"maintainers":[{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/push-receiver_2.2.2_1709420604712_0.5247307064942017"},"_hasShrinkwrap":false},"2.3.0":{"name":"@alicenewberry/push-receiver","version":"2.3.0","description":"A module to subscribe to GCM/FCM and receive notifications within a node process.","main":"src/index.js","scripts":{"start":"node scripts/listen","register":"node scripts/register","send":"node scripts/send","pretty":"prettier-eslint --single-quote --trailing-comma es5 --write \"**/*.js\" \"**/*.json\"","pretty:check":"prettier-eslint --single-quote --trailing-comma es5 --list-different --log-level silent \"**/*.js\" \"**/*.json\"","lint":"eslint 'src/**/*.js'","lint:fix":"eslint 'src/**/*.js' --fix","test":"jest","precommit":"lint-staged"},"lint-staged":{"*.js":["eslint --fix","prettier-eslint --single-quote --trailing-comma es5 --write"],"*.json":["prettier-eslint --single-quote --trailing-comma es5 --write"]},"repository":{"type":"git","url":"git+https://github.com/isaleoff/push-receiver.git"},"keywords":["push","service","fcm","gcm","notifications","node","electron","receiver"],"author":{"name":"alicenewberry"},"license":"MIT","bugs":{"url":"https://github.com/isaleoff/push-receiver/issues"},"homepage":"https://github.com/isaleoff/push-receiver#readme","devDependencies":{"babel-eslint":"^7.2.3","eslint":"^4.4.1","eslint-plugin-jest":"^20.0.3","http-proxy":"^1.16.2","husky":"^0.14.3","jest":"^22.2.2","lint-staged":"^6.1.0","prettier":"^1.6.1","prettier-eslint":"^7.0.0","prettier-eslint-cli":"^4.3.0","yargs":"^10.0.3"},"dependencies":{"http_ece":"^1.0.5","long":"^3.2.0","protobufjs":"^6.8.0","request":"^2.81.0","request-promise":"^4.2.1","uuid":"^3.1.0"},"_id":"@alicenewberry/push-receiver@2.3.0","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-tcFwboX9bTL6eRGmJZK38OjQwySZNQ8idh8U6CfqXNuv7QmCR7Xi5JYbD4y9H9tbWtGr38SO3fWyJAno9WENFg==","shasum":"5f36f0d301fbddfe756b9027d22e0e5aabd00ebd","tarball":"https://registry.npmjs.org/@alicenewberry/push-receiver/-/push-receiver-2.3.0.tgz","fileCount":25,"unpackedSize":56346,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEBOdFXbhLrpDAsL7VAZ/7XUM00qANPD3vGPa2MJKhxdAiEA/owUsHcyr0X8vkLeDJRsWJaTJD97ioMeHqVV9puQb+c="}]},"_npmUser":{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"},"directories":{},"maintainers":[{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/push-receiver_2.3.0_1710176163380_0.7519414202835597"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-27T18:36:28.362Z","2.1.1":"2024-02-27T18:36:28.737Z","modified":"2024-03-11T16:56:04.001Z","2.2.2":"2024-03-02T23:03:24.851Z","2.3.0":"2024-03-11T16:56:03.585Z"},"maintainers":[{"name":"alicenewberry","email":"alicenewberry34662@gmail.com"}],"description":"A module to subscribe to GCM/FCM and receive notifications within a node process.","homepage":"https://github.com/isaleoff/push-receiver#readme","keywords":["push","service","fcm","gcm","notifications","node","electron","receiver"],"repository":{"type":"git","url":"git+https://github.com/isaleoff/push-receiver.git"},"author":{"name":"alicenewberry"},"bugs":{"url":"https://github.com/isaleoff/push-receiver/issues"},"license":"MIT","readme":"# push-receiver\n\nA library to subscribe to GCM/FCM and receive notifications within a node process.\n\nFor [Electron](https://github.com/electron/electron), you can use [electron-push-receiver](https://github.com/MatthieuLemoine/electron-push-receiver) instead which provides a convenient wrapper.\n\nSee [this blog post](https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0) for more details.\n\n## When should I use `push-receiver` ?\n\n- I want to **receive** push notifications sent using Firebase Cloud Messaging in an [electron](https://github.com/electron/electron) desktop application.\n- I want to communicate with a node process/server using Firebase Cloud Messaging infrastructure.\n\n## When should I not use `push-receiver` ?\n\n- I want to **send** push notifications (use the firebase SDK instead)\n- My application is running on a FCM supported platform (Android, iOS, Web).\n\n## Install\n\n`\nnpm i -S @alicenewberry/push-receiver\n`\n\n## Requirements\n\n- Node v8 (async/await support)\n- Firebase sender id to receive notification\n- Firebase serverKey to send notification (optional)\n\n## Usage\n\n### Electron\n\nYou can use [electron-push-receiver](https://github.com/MatthieuLemoine/electron-push-receiver) instead which provides a convenient wrapper.\n\n### Node\n\n```javascript\nconst { register, listen } = require('push-receiver');\n\n// First time\n// Register to GCM and FCM\nconst credentials = await register(senderId); // You should call register only once and then store the credentials somewhere\nstoreCredentials(credentials) // Store credentials to use it later\nconst fcmToken = credentials.fcm.token; // Token to use to send notifications\nsendTokenToBackendOrWhatever(fcmToken);\n\n\n// Next times\nconst credentials = getSavedCredentials() // get your saved credentials from somewhere (file, db, etc...)\n// persistentIds is the list of notification ids received to avoid receiving all already received notifications on start.\nconst persistentIds = getPersistentIds() || [] // get all previous persistentIds from somewhere (file, db, etc...)\nawait listen({ ...credentials, persistentIds}, onNotification);\n\n// Called on new notification\nfunction onNotification({ notification, persistentId }) {\n  // Update list of persistentId in file/db/...\n  updatePersistentIds([...persistentIds, persistentId]);\n  // Do someting with the notification\n  display(notification)\n}\n```\n\n### Test notification\n\nTo test, you can use the [send script](scripts/send/index.js) provided in this repo, you need to pass your serverKey and the FCM token as arguments :\n\n```\nnode scripts/send --serverKey=\"<FIREBASE_SERVER_KEY>\" --token=\"<FIREBASE_TOKEN>\"\n```\n","readmeFilename":"README.md"}