{"_id":"@elozino/fcm-notification","_rev":"3-e29519bd37fc62f83dae8e9057570560","name":"@elozino/fcm-notification","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@elozino/fcm-notification","version":"1.0.0","keywords":["FCM","Firebase","Push","Notification","React","React Native"],"author":{"name":"Elozino Ovedhe"},"license":"ISC","_id":"@elozino/fcm-notification@1.0.0","maintainers":[{"name":"elozino","email":"ovedhee@gmail.com"}],"homepage":"https://github.com/Elozino/fcm-notification#readme","bugs":{"url":"https://github.com/Elozino/fcm-notification/issues"},"dist":{"shasum":"e262860dc67bbb21a27ff54c0ea9063d1f081486","tarball":"https://registry.npmjs.org/@elozino/fcm-notification/-/fcm-notification-1.0.0.tgz","fileCount":9,"integrity":"sha512-ZLBRZ/1GpN5wDotXos/D2RSH7g9CbdUdfYDoPWWejLQ9INEfpS+JPedXpSmjqgs8BXyFuCpFefw+YOpR3v12BQ==","signatures":[{"sig":"MEYCIQCsfAKgVcPBsYfqlkHxMZphqH4WnnVxqaQbZrnC6ZqhvQIhAIHjQzqAHh9yqXAbvEKpYVeAhlplihcYlUX+AGqjIs7j","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19775},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"5520d60af2d0dc47aac9ae11fbcd3805018530e0","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"elozino","email":"ovedhee@gmail.com"},"repository":{"url":"git+https://github.com/Elozino/fcm-notification.git","type":"git"},"_npmVersion":"10.2.3","description":"A library to send fcm push notification from the client app","directories":{},"_nodeVersion":"20.17.0","dependencies":{"firebase-admin":"^13.0.0"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"typescript":"^5.6.3","@types/node":"^22.9.0"},"_npmOperationalInternal":{"tmp":"tmp/fcm-notification_1.0.0_1731873091393_0.7834968357529255","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@elozino/fcm-notification","version":"1.1.0","keywords":["FCM","Firebase","Push","Notification","React","React Native"],"author":{"name":"Elozino Ovedhe"},"license":"ISC","_id":"@elozino/fcm-notification@1.1.0","maintainers":[{"name":"elozino","email":"ovedhee@gmail.com"}],"homepage":"https://github.com/Elozino/fcm-notification#readme","bugs":{"url":"https://github.com/Elozino/fcm-notification/issues"},"dist":{"shasum":"14f1786a4e9918d795537f64789b1a5d51eb3d32","tarball":"https://registry.npmjs.org/@elozino/fcm-notification/-/fcm-notification-1.1.0.tgz","fileCount":4,"integrity":"sha512-DS+RFuqc1HwCdpHOG+03WU4dI/X+TQyTESFEn0jPDiXiJj2GlHtmnCtYgAOywzFEo9vDraaA5yJRv9rc9ychLg==","signatures":[{"sig":"MEQCIFI2STQxnynQ+a91mlXV4w0h9+MemdgMBFtcbbwje83KAiBUx3RN2Wh6tmSDsZDGNxhhVCWiJw8wGk2YWhwOtDfvRQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11808},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"9d3343edb102596d24e706ed4983a796075c2cf4","scripts":{"dev":"ts-node src/index.ts","test":"jest","build":"tsc","prepare":"yarn build"},"_npmUser":{"name":"elozino","email":"ovedhee@gmail.com"},"repository":{"url":"git+https://github.com/Elozino/fcm-notification.git","type":"git"},"_npmVersion":"10.2.3","description":"A library to send fcm push notification from the client app","directories":{},"_nodeVersion":"22.14.0","dependencies":{"firebase-admin":"^13.4.0","google-auth-library":"^9.15.1"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"jest":"^29.7.0","ts-jest":"^29.3.4","ts-node":"^10.9.2","typescript":"^5.8.3","@types/jest":"^29.5.14","@types/node":"^22.15.21"},"_npmOperationalInternal":{"tmp":"tmp/fcm-notification_1.1.0_1748071834456_0.6401857109491171","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@elozino/fcm-notification","version":"1.1.1","description":"A library to send fcm push notification from the client app","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"yarn build","test":"jest","dev":"ts-node src/index.ts"},"repository":{"type":"git","url":"git+https://github.com/Elozino/fcm-notification.git"},"keywords":["FCM","Firebase","Push","Notification","React","React Native"],"author":{"name":"Elozino Ovedhe"},"license":"ISC","packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"@types/jest":"^29.5.14","@types/node":"^22.15.21","jest":"^29.7.0","ts-jest":"^29.3.4","ts-node":"^10.9.2","typescript":"^5.8.3"},"dependencies":{"firebase-admin":"^13.4.0","google-auth-library":"^9.15.1"},"_id":"@elozino/fcm-notification@1.1.1","gitHead":"abbe4ce4c39d381ea1e389a3cb0c5f1075633ef1","bugs":{"url":"https://github.com/Elozino/fcm-notification/issues"},"homepage":"https://github.com/Elozino/fcm-notification#readme","_nodeVersion":"22.14.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-dXDOhf1vXuauw1J37qSN5aOL73Yj5lGvy0DJJdxC5BJ+gmpypK3YQNMDX9khcE91n3ozD87q7TWWf94tlWH14Q==","shasum":"60b42346acb1f3b9e40257d1cc364b73db2b9a37","tarball":"https://registry.npmjs.org/@elozino/fcm-notification/-/fcm-notification-1.1.1.tgz","fileCount":10,"unpackedSize":20306,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCtjWTxV6EiJ225OZccqtiSb5p6XSnWM48hfiKTzvGWNgIhAMCGc7a2nnwgQjQnqP5uWX5bNwoKnq/JtliStY5TTjDj"}]},"_npmUser":{"name":"elozino","email":"ovedhee@gmail.com"},"directories":{},"maintainers":[{"name":"elozino","email":"ovedhee@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fcm-notification_1.1.1_1748075438802_0.381962870110079"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-17T19:51:31.295Z","modified":"2025-05-24T08:30:39.201Z","1.0.0":"2024-11-17T19:51:31.560Z","1.1.0":"2025-05-24T07:30:34.614Z","1.1.1":"2025-05-24T08:30:39.018Z"},"bugs":{"url":"https://github.com/Elozino/fcm-notification/issues"},"author":{"name":"Elozino Ovedhe"},"license":"ISC","homepage":"https://github.com/Elozino/fcm-notification#readme","keywords":["FCM","Firebase","Push","Notification","React","React Native"],"repository":{"type":"git","url":"git+https://github.com/Elozino/fcm-notification.git"},"description":"A library to send fcm push notification from the client app","maintainers":[{"name":"elozino","email":"ovedhee@gmail.com"}],"readme":"# Firebase Notification Library\r\n\r\nA simple TypeScript-based library to send Firebase Cloud Messaging (FCM) notifications. This library makes it easy to integrate or test Firebase notifications into your applications.\r\n\r\n\r\n<p style=\"font-size: 20px\">Installation</p>\r\n\r\n```bash\r\nnpm install @elozino/fcm-notification\r\n```\r\nor\r\n\r\n```bash\r\nyarn add @elozino/fcm-notification\r\n```\r\n\r\n## Usage\r\n\r\n### 1. Import the library:\r\n```typescript\r\nimport { initializeFirebase, sendNotification } from \"@elozino/fcm-notification\";\r\n```\r\n\r\n### 2. Initialize Firebase:\r\n\r\n```typescript\r\nimport serviceAccount from \"./path-to-your-google-service-account.json\";\r\n\r\nconst app = initializeFirebase({\r\n  serviceAccount: serviceAccount as admin.ServiceAccount,\r\n});\r\n\r\nconsole.log(\"Firebase initialized:\", app);\r\n```\r\n\r\nExample Service Account File ```(serviceAccount.json)```\r\n\r\n```json\r\n{\r\n  \"type\": \"service_account\",\r\n  \"project_id\": \"your-project-id\",\r\n  \"private_key_id\": \"your-private-key-id\",\r\n  \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nYOUR_PRIVATE_KEY\\n-----END PRIVATE KEY-----\\n\",\r\n  \"client_email\": \"your-client-email@your-project-id.iam.gserviceaccount.com\",\r\n  \"client_id\": \"your-client-id\",\r\n  \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\r\n  \"token_uri\": \"https://oauth2.googleapis.com/token\",\r\n  \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\r\n  \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/your-client-email\"\r\n}\r\n```\r\n\r\n### 3. Send a notification:\r\nOnce Firebase is initialized, you can send notifications to devices using their FCM tokens:\r\n\r\n```typescript\r\nconst token = \"your-device-token\";\r\n\r\nsendNotification({\r\n  token,\r\n  title: \"Hello!\",\r\n  body: \"This is a test notification.\"\r\n})\r\n  .then(() => console.log(\"Notification sent successfully!\"))\r\n  .catch((err) => console.error(\"Failed to send notification:\", err));\r\n  \r\nawait sendBatchNotifications([\r\n  {\r\n    token: 'token1',\r\n    title: 'Hello 1',\r\n    body: 'Message 1'\r\n  },\r\n  {\r\n    token: 'token2',\r\n    title: 'Hello 2',\r\n    body: 'Message 2'\r\n  }\r\n]);\r\n\r\nsendNotificationViaHTTP_V1({\r\n  token,\r\n  title: \"Hello!\",\r\n  body: \"This is from a frontend app notification.\"\r\n})\r\n\r\n## PS: `sendNotificationFromFrontend` uses the HTTP v1\r\n```\r\n\r\n\r\n\r\n### API Reference\r\n| Name | Type | Description |\r\n| ------ | ------ | ------ |\r\n| serviceAccount | ```ServiceAccount``` | The service account object containing the credentials for Firebase. |\r\n| token | ```string``` | The FCM token of the device you want to send the notification to. |\r\n| title |```string``` | The title of the notification. |\r\n| body | ```string``` | The body of the notification. |","readmeFilename":"README.md"}