{"id":15043808,"url":"https://github.com/rixcian/firebase-electron","last_synced_at":"2025-04-14T23:12:46.590Z","repository":{"id":254968798,"uuid":"848096633","full_name":"rixcian/firebase-electron","owner":"rixcian","description":"Receive a Firebase notifications in your Electron app","archived":false,"fork":false,"pushed_at":"2024-10-08T13:45:21.000Z","size":366,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T23:12:39.076Z","etag":null,"topics":["electron","fcm","firebase","firebase-cloud-messaging","gcm","nodejs","notifications","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/firebase-electron","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/rixcian.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-08-27T05:58:43.000Z","updated_at":"2025-03-09T18:49:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdd36dec-e947-47e5-844b-a28875b02816","html_url":"https://github.com/rixcian/firebase-electron","commit_stats":null,"previous_names":["rixcian/firebase-electron"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixcian%2Ffirebase-electron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixcian%2Ffirebase-electron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixcian%2Ffirebase-electron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rixcian%2Ffirebase-electron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rixcian","download_url":"https://codeload.github.com/rixcian/firebase-electron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975328,"owners_count":21192210,"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","gcm","nodejs","notifications","typescript"],"created_at":"2024-09-24T20:49:37.639Z","updated_at":"2025-04-14T23:12:46.561Z","avatar_url":"https://github.com/rixcian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# firebase-electron\n\nReceive Firebase push notifications in your Electron app.\n\n## Installation\n\n```bash\nnpm i firebase-electron\n```\n\n## Usage\n\nUsage is similar to the [`electron-push-receiver`](https://github.com/MatthieuLemoine/electron-push-receiver) package.\n\n### In the main process (`main.js/.ts`)\n\n```typescript\nimport { setup: setupPushReceiver } from 'firebase-electron';\n\n// Call it before 'did-finish-load' with mainWindow a reference to your window\nsetupPushReceiver(mainWindow.webContents);\n```\n\n### In the renderer process (`renderer.js/.ts`)\n\n```typescript\nimport { ipcRenderer } from 'electron';\nimport {\n  START_NOTIFICATION_SERVICE,\n  NOTIFICATION_SERVICE_STARTED,\n  NOTIFICATION_SERVICE_ERROR,\n  NOTIFICATION_RECEIVED,\n  TOKEN_UPDATED,\n} from 'firebase-electron/dist/electron/consts';\n\n// Listen for service successfully started\nipcRenderer.on(NOTIFICATION_SERVICE_STARTED, (_, token) =\u003e {\n  // do something\n});\n// Handle notification errors\nipcRenderer.on(NOTIFICATION_SERVICE_ERROR, (_, error) =\u003e {\n  // do something\n});\n// Send FCM token to backend\nipcRenderer.on(TOKEN_UPDATED, (_, token) =\u003e {\n  // Send token\n});\n// Display notification\nipcRenderer.on(NOTIFICATION_RECEIVED, (_, notification) =\u003e {\n  // display notification\n});\n// Start service\nipcRenderer.send(START_NOTIFICATION_SERVICE, { appId, apiKey, projectId, vapidKey });\n// or\nwindow.ipc.send(START_NOTIFICATION_SERVICE, { appId, apiKey, projectId, vapidKey });\n```\n\n### Where to find `appId`, `apiKey`, `projectId` and `vapidKey`\n\n1. Go to [Firebase Console](https://console.firebase.google.com/) \u0026 login to your account\n2. Select your project\n3. Click on the `Project Settings` cog icon\n4. Click on `Project Settings`\n5. Make sure you're on the `General` tab\n6. Scroll down to the `Your apps` section\n7. If you don't have an app, click on `Add app`\n   - Select `Web`\n   - Fill in the required fields\n   - Click on `Register`\n8. Copy the `appId`, `apiKey`, `projectId` listed under the `SDK setup and configuration` section\n9. (Optional) Copy the `vapidKey` listed under the `Cloud Messaging` tab and `Web Configuration \u003e Web Push certificates` section\n10. (Optional) Generate a new `key pair` and use the value in the `Key pair` column as your `vapidKey`\n\n## Moving from `electron-push-receiver`\n\n[`electron-push-receiver`](https://github.com/MatthieuLemoine/electron-push-receiver) library stopped working because it depends on the [Legacy FCM API](https://firebase.google.com/docs/cloud-messaging/migrate-v1) which was deprecated on June 21st, 2024 by Google.\n\nThis package is a fork of the `electron-push-receiver` package that has been updated to work with the new Firebase Cloud Messaging (FCM) protocol.\n\nI'm giving all credits to [Matthieu Lemoine](https://github.com/MatthieuLemoine) for the initial work and all the contributors for the `electron-push-receiver` package. I only updated the package to work with the new FCM protocol.\n\n### What's new\n\n- Uses the new FCM protocol ([HTTP v1 API](https://firebase.google.com/docs/cloud-messaging/migrate-v1))\n- Uses updated dependencies (without any critical vulnerabilities)\n- Remove unnecessary, deprecated and vulnerable dependencies (e.g. `request-promise`, `electron-config`)\n- Simplified the codebase\n- Latest Node.js (v22)\n- Refactor tests and use [vitest](https://vitest.dev/) for testing\n- Completely written in TypeScript\n\n\u003e [!CAUTION]\n\u003e Breaking changes - Instead of providing just a `senderId`, you now must provide `appId`, `apiKey`, `projectId` and optionally a `vapidKey`. See the updated [usage example](#usage).\n\u003e\n\u003e \u003e Google deprecated https://fcm.googleapis.com/fcm/connect/subscribe (/send too), which is slated for full removal on June 22, 2024. (Source: https://firebase.google.com/docs/cloud-messaging/migrate-v1)\n\n## Development\n\n1. Make sure you have the right Node.js version installed (specified in `.nvmrc` file)\n2. Install dependencies with `npm install`\n3. Duplicate `.env.template` to `.env` and fill in the required fields\n4. Run tests with `npm run test`\n5. Everything should works :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frixcian%2Ffirebase-electron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frixcian%2Ffirebase-electron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frixcian%2Ffirebase-electron/lists"}