{"id":26942837,"url":"https://github.com/miafoo/fcm-web-push","last_synced_at":"2025-07-28T16:09:58.305Z","repository":{"id":221810551,"uuid":"755262782","full_name":"miafoo/fcm-web-push","owner":"miafoo","description":"A very minimal web push notification server using Firebase Cloud Messaging (FCM) for Node (and Electron).","archived":false,"fork":false,"pushed_at":"2024-02-16T19:47:31.000Z","size":73,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-04T21:01:55.003Z","etag":null,"topics":["electron","fcm","firebase","firebase-cloud-messaging","node","notifications","push-notifications","webpush"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miafoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-09T19:07:11.000Z","updated_at":"2025-02-26T09:34:52.000Z","dependencies_parsed_at":"2025-03-04T21:01:07.207Z","dependency_job_id":"cdae7fb8-ed08-4654-a5da-4003845e2aac","html_url":"https://github.com/miafoo/fcm-web-push","commit_stats":null,"previous_names":["miafoo/fcm-web-push"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miafoo%2Ffcm-web-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miafoo%2Ffcm-web-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miafoo%2Ffcm-web-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miafoo%2Ffcm-web-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miafoo","download_url":"https://codeload.github.com/miafoo/fcm-web-push/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246856056,"owners_count":20844969,"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":["electron","fcm","firebase","firebase-cloud-messaging","node","notifications","push-notifications","webpush"],"created_at":"2025-04-02T16:50:33.871Z","updated_at":"2025-04-02T16:50:34.507Z","avatar_url":"https://github.com/miafoo.png","language":"TypeScript","readme":"[![npm version](https://badge.fury.io/js/@miafoo%2Ffcm-web-push.svg)](https://badge.fury.io/js/@miafoo%2Ffcm-web-push)\n\nA very minimal web push notification server using Firebase Cloud Messaging (FCM) for Node (and Electron).\n\n# Installation\n\n```bash\nnpm install @miafoo/fcm-web-push\n```\n\n# Prerequisites\n\n1. Firebase App ID\n2. Firebase Project ID\n3. Firebase API Key\n4. Firebase VAPID/Key Pair\n\nYou can find the first 3 in the Firebase Console when you create a new \"Web app\". The VAPID/Key pair can be found in the \"Web configuration\" section on the \"Cloud Messaging\" tab.\n\n# Usage\n\nSee [examples](./examples/) folder for more complete examples than the one below.\n\n```typescript\nimport { register, FcmClient } from \"@miafoo/fcm-web-push\"\n\n// Restore persistentIds from the previous session.\nconst previousPersistentIds: string[] = readPersistentIdsFromDisk()\nconst newPersistentIds: string[] = []\n\n// Register the app with Firebase. Ideally you would store this registration\n// and restore it next time you run the app.\n// You can use the `encodeRegistration` and `decodeRegistration` functions\n// to easily save and restore the registration as JSON strings.\n// Note: Registration can take several seconds.\nconst registration = await register({\n  apiKey: \"xxxx\",\n  projectId: \"xxxx\",\n  appId: \"xxxx\",\n  vapidKey: \"xxxx\",\n})\n\nconst client = new FcmClient({\n  registration,\n})\n\nclient.on(\"connect\", () =\u003e {\n  console.log(\"Connecting...\")\n})\n\nclient.on(\"connected\", () =\u003e {\n  console.log(\"Connected!\")\n})\n\nclient.on(\"disconnected\", () =\u003e {\n  console.log(\"Disconnected!\")\n})\n\nclient.on(\"message\", (message) =\u003e {\n  // Store the `persistentId`!\n  newPersistentIds.push(message.persistentId)\n  console.log(message)\n})\n\n// Pass in the `previousPersistentIds` to mark them seen, otheriwse they\n// will be received again every time the client connects.\nawait client.connect(previousPersistentIds)\n// Note: The `connect` promise resolves when the socket is closed.\n// You can also close the socket manually by disconnecting:\nclient.disconnect()\n\n// Save the new persistent ids so we can mark them seen next time we run.\nwritePersistentIdsToDisk(newPersistentIds)\n```\n\n# Acknowledgements\n\n- [push-receiver](https://github.com/MatthieuLemoine/push-receiver) for the original implementation. Be sure to check out Matthieu Lemoine's [blog post](https://medium.com/@MatthieuLemoine/my-journey-to-bring-web-push-support-to-node-and-electron-ce70eea1c0b0) on how they built it.\n- [fcm-push-listener](https://github.com/RandomEngy/fcm-push-listener) for a simple Rust implementation. Large portion of this code is based on it.\n- Google \u0026 Chrome Developer blogs for the [Web Push Protocol](https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol) and [Web Push Encryption](https://developer.chrome.com/blog/web-push-encryption).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiafoo%2Ffcm-web-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiafoo%2Ffcm-web-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiafoo%2Ffcm-web-push/lists"}