{"id":19283220,"url":"https://github.com/ankushtechdev/nodejs-firebase-push-notification-for-ios-device","last_synced_at":"2025-02-23T22:26:29.298Z","repository":{"id":203452630,"uuid":"357824604","full_name":"AnkushTechDev/nodejs-firebase-push-notification-for-ios-device","owner":"AnkushTechDev","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-01T06:49:49.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-05T17:29:09.019Z","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:06:12.000Z","updated_at":"2021-05-01T06:49:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"8521b7d8-1abf-4857-bd0d-5c36f06d11c1","html_url":"https://github.com/AnkushTechDev/nodejs-firebase-push-notification-for-ios-device","commit_stats":null,"previous_names":["lazybrucewayne/nodejs-firebase-push-notification-for-ios-device","ankushtechdev/nodejs-firebase-push-notification-for-ios-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-ios-device","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-ios-device/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-ios-device/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnkushTechDev%2Fnodejs-firebase-push-notification-for-ios-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-ios-device/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240387426,"owners_count":19793349,"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:15.119Z","updated_at":"2025-02-23T22:26:29.270Z","avatar_url":"https://github.com/AnkushTechDev.png","language":"JavaScript","readme":"# Nodejs firebase push notification for ios 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\n    static async sendIos(data) {\n        try {\n            var note = new apn.Notification();\n            note.expiry = Math.floor(Date.now() / 1000) + 7200; // Expires 1 hour from now.\n            note.badge = data.badge;\n            note.sound = \"ping.aiff\";\n            note.alert = {\n                title: data.title,\n                body: data.message\n            };\n            note.topic = config.topic;\n            note.mutableContent = 1;\n            note.payload = data\n            note.aps['content-available'] = 1;\n\n            let deviceToken = data.deviceToken;\n            apnProvider.send(note, deviceToken).then((success) =\u003e {\n                if (success) {\n                    console.log(\"from success\", success.failed)\n                    return success;\n                }\n            });\n\n        } catch (err) {\n            console.log(\"Push Notification error- \", err);\n            return ({\n                message: err,\n                status: 0\n            });\n        }\n    }\n}\nmodule.exports = PushNotification\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-ios-device","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-ios-device","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankushtechdev%2Fnodejs-firebase-push-notification-for-ios-device/lists"}