{"id":19283222,"url":"https://github.com/ankushtechdev/nodejs-firebase-push-notification-for-android-device","last_synced_at":"2025-07-08T19:36:48.601Z","repository":{"id":203452628,"uuid":"357823248","full_name":"AnkushTechDev/nodejs-firebase-push-notification-for-android-device","owner":"AnkushTechDev","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-01T06:48:01.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-05T17:29:09.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnkushTechDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-04-14T08:01:31.000Z","updated_at":"2021-11-11T02:45:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd2ccf2e-12ef-4dd2-9205-b73be86837f3","html_url":"https://github.com/AnkushTechDev/nodejs-firebase-push-notification-for-android-device","commit_stats":null,"previous_names":["lazybrucewayne/nodejs-firebase-push-notification-for-android-device","ankushtechdev/nodejs-firebase-push-notification-for-android-device"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-android-device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-android-device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-android-device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-android-device/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnkushTechDev","download_url":"https://codeload.github.com/AnkushTechDev/nodejs-firebase-push-notification-for-android-device/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240387422,"owners_count":19793348,"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":[],"created_at":"2024-11-09T21:30:16.436Z","updated_at":"2025-02-23T22:26:27.028Z","avatar_url":"https://github.com/AnkushTechDev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nodejs firebase push notification for android device\n\n```js\nlet FCM = require('fcm-node');\nimport config from '../config'\nvar apn = require('apn');\nlet path = require('path');\nlet fs = require('fs');\n\n// Set up apn with the APNs Auth Key\nlet apnProvider = new apn.Provider({\n    token: {\n        key: fs.readFileSync(path.resolve(__dirname + '/file.p8')),\n        keyId: config.keyId, // The Key ID of the p8 file (available at https://developer.apple.com/account/ios/certificate/key)\n        teamId: config.teamId, // The Team ID of your Apple Developer Account (available at https://developer.apple.com/account/#/membership/)\n    },\n    production: true // Set to true if sending a notification to a production iOS app\n});\n\n\nclass PushNotification {\n    static async sendAndroid(data) {\n        return new Promise((resolve, reject) =\u003e {\n            var serverKey = config.serverKey; //put your server key here\n            var fcm = new FCM(serverKey);\n\n            var message = { //this may vary according to the message type (single recipient, multicast, topic, et cetera)\n                to: data.deviceToken,\n                collapse_key: config.collapse_key,\n                notification: {\n                    title: data.title,\n                    body: data.message\n                },\n                data: { //you can send only notification or only data(or include both)\n                    data: data\n                }\n            };\n            fcm.send(message, function(err, response) {\n                if (err) {\n                    console.log(\"Something has gone wrong!\", err);\n                    reject(err);\n                } else {\n                    resolve(response);\n                    console.log(\"Successfully sent with response: \", response);\n                }\n            });\n\n        })\n    }\n\n}\nmodule.exports = PushNotification\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-android-device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-android-device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-android-device/lists"}