{"_id":"@chandrashekar998/fcm-notify","_rev":"1-dd8c81ddeeacd78ff684a78e91cedaa1","name":"@chandrashekar998/fcm-notify","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@chandrashekar998/fcm-notify","version":"0.1.0","description":"A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM). Supports both android and iOS, including topic messages, and parallel calls.\nAditionally it also keeps the callback behavior for the new firebase messaging service.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/jlcvp/fcm-node.git"},"keywords":["fcm","gcm","push","notification","push notification","firebase","firebase cloud messaging","google","android","ios","topic message","parallel send"],"author":{"name":"chandrashekar998","email":"chandrashekar998@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/chandrashekar3792/fcm-notify/issues"},"homepage":"https://github.com/chandrashekar3792/fcm-notify","dependencies":{"firebase-admin":"^9.2.0","https-proxy-agent":"^2.2.3","retry":"^0.12.0","snyk":"^1.316.1"},"devDependencies":{"mocha":"^4.0.1"},"scripts":{"test":"mocha --exit","debugtest":"mocha --debug-brk $npm_package_options_mocha --exit","snyk-protect":"snyk protect","prepare":"npm run snyk-protect"},"directories":{"lib":"lib","test":"test"},"tonicExampleFilename":"example.js","snyk":true,"gitHead":"7bfbdaf312d67da5e7f85bac9dfc15e165f67bc9","_id":"@chandrashekar998/fcm-notify@0.1.0","_nodeVersion":"12.19.0","_npmVersion":"6.14.9","dist":{"integrity":"sha512-0f0JWQupZ3bnxMa2h2LSvg/GhGcFMsoCUATFqH1Z5IAH6lclwJ4wO2KjSV1lz6Pzb0sFI2n78nHomSKDMzxjlA==","shasum":"579b10dfd6e8d9e572ed5847f5083be30f6eef9d","tarball":"https://registry.npmjs.org/@chandrashekar998/fcm-notify/-/fcm-notify-0.1.0.tgz","fileCount":16,"unpackedSize":31004,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfzdm6CRA9TVsSAnZWagAAVW8P/3wUZ4PmC1ytMSXFjMNY\naHV1gdA53Ghs/mmaTzl32SF4h4R1R2ejGdy7Fz4vsewdCJhf7bEFFcobRQ/H\niGPoDSivoE86eS0tWprJ9sBo/0w84waCOXX8OUG986Y1drgro8QStb0V41e3\nDA2wkNZIPRcI7UsxNBc6hbHHyYAw7aaz9ywv3rUh+qrMMh2WwHvqWudbqg98\niYC/08aB8cuFd6ue+xT8p9UC62LkP2z7ZBxszgxRiaEGgJxr0fPFIO6IMaJC\ndJroUsliMQIpxUAuMfXOs1AW6JsZPZznTxrnefHBFOYLL1ifMpp5BBiQbpC4\nA0T8Rmgyx/M0XHvcl7tnTIzNbZ3AVDZzaQIGOJX47HOa+u/JNt0KQ6TNopa2\nJ1ewhvOHoI6zxCSe/0ZEoYymi7sM25xYRgLVbPMeIJOARj7jhi9WzlVW/UqN\ne03DdfY7JO2BvC3gpB5t/Qqa1HeV9Eyi2gUd93uZ77vnNUod6H/FlUCE8i5g\nk6nqCwMPd9BjsgWJW9e3nyHjQrvSIeppM1TEyMeAWW4Tvr70PY+PXbbTekpA\nomR6BcogYfX4mJi3W0E1TIBB21uZ3mrLJIQsfLoF1A2yVA2JNzm96mJVIvy2\nNV3Ndb940uHtNPaLRzQS5Mn0DK2i9yfpQcqmvrnZB/ogSwsOWs+TGQTZ5QgI\nq5LK\r\n=/3Fg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF13ZTUXAWp9u1orRgKq3heStRWRzqYTT4sH0DLd/zUVAiBwDjEicqqezBg7gI3YuCOjOM4sb7cM+kgETC122R2bYw=="}]},"_npmUser":{"name":"chandrashekar998","email":"chandrashekar998@gmail.com"},"maintainers":[{"name":"chandrashekar998","email":"chandrashekar998@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fcm-notify_0.1.0_1607326138179_0.15806624897439048"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-07T07:28:58.145Z","0.1.0":"2020-12-07T07:28:58.307Z","modified":"2022-04-04T22:30:10.478Z"},"maintainers":[{"name":"chandrashekar998","email":"chandrashekar998@gmail.com"}],"description":"A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM). Supports both android and iOS, including topic messages, and parallel calls.\nAditionally it also keeps the callback behavior for the new firebase messaging service.","homepage":"https://github.com/chandrashekar3792/fcm-notify","keywords":["fcm","gcm","push","notification","push notification","firebase","firebase cloud messaging","google","android","ios","topic message","parallel send"],"repository":{"type":"git","url":"git+https://github.com/jlcvp/fcm-node.git"},"author":{"name":"chandrashekar998","email":"chandrashekar998@gmail.com"},"bugs":{"url":"https://github.com/chandrashekar3792/fcm-notify/issues"},"license":"MIT","readme":"### Warning: on February 2, 2017, the Firebase Team [released][11] the [_admin.messaging()_][12] service to their node.js admin module. This new service makes this module kind of *deprecated*  \n\nfcm-node [![NPM version](https://badge.fury.io/js/fcm-node.svg)](http://badge.fury.io/js/fcm-node)\n========\nA Node.JS simple interface to Google's Firebase Cloud Messaging (FCM). Supports both android and iOS, including topic messages, and parallel calls.  \nAditionally it also keeps the callback behavior for the new firebase messaging service. \n## Installation\n\nVia [npm][1]:\n\n    $ npm install fcm-notify\n\n## Usage\n\nThere are 2 ways to use this lib:\n### The **classic** one \n   1. Generate a **Server Key** on your app's firebase console and pass it to the **FCM** constructor\n   2. Create a _message object_ and call the **send()** function\n#### Classic usage example:\n```js\n    var FCM = require('fcm-node');\n    var serverKey = 'YOURSERVERKEYHERE'; //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: 'registration_token', \n        collapse_key: 'your_collapse_key',\n        \n        notification: {\n            title: 'Title of your push notification', \n            body: 'Body of your push notification' \n        },\n        \n        data: {  //you can send only notification or only data(or include both)\n            my_key: 'my value',\n            my_another_key: 'my another value'\n        }\n    };\n    \n    fcm.send(message, function(err, response){\n        if (err) {\n            console.log(\"Something has gone wrong!\");\n        } else {\n            console.log(\"Successfully sent with response: \", response);\n        }\n    });\n```\n\n### The **new** one \n   1. Go to your [Service account tab][13] in your project's settings and download/generate your app's private key. \n   2. Add this file in your project's workspace\n   3. Import that file with a `require('path/to/privatekey.json')` style call and pass the object to the **FCM** constructor\n   4. Create a _message object_ and call the **send()** function\n   \n#### \"New\" usage example\n```js\n    var FCM = require('fcm-node')\n    \n    var serverKey = require('path/to/privatekey.json') //put the generated private key path here    \n    \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: 'registration_token', \n        collapse_key: 'your_collapse_key',\n        \n        notification: {\n            title: 'Title of your push notification', \n            body: 'Body of your push notification' \n        },\n        \n        data: {  //you can send only notification or only data(or include both)\n            my_key: 'my value',\n            my_another_key: 'my another value'\n        }\n    }\n    \n    fcm.send(message, function(err, response){\n        if (err) {\n            console.log(\"Something has gone wrong!\")\n        } else {\n            console.log(\"Successfully sent with response: \", response)\n        }\n    })\n```\n\n## Topic subscription on web clients\n\nWeb clients doesn't have a \"native\" way to subscribe/unsubscribe from topics other than manually requesting, managing and registering with the google's iid servers. To resolve this \"barrier\" your server can easily handle the web client's sub/unsub requests with this lib.\n\nFor more detailed information, please take a look at [Google InstanceID Reference][14].\n\n*PS: For mobile clients you can still use the native calls to subscribe/unsubscribe with one-liner calls*\n##### Android\n```java\nFirebaseMessaging.getInstance().subscribeToTopic(\"news\");\n```\n##### iOS\n```objective-c\n[[FIRMessaging messaging] subscribeToTopic:@\"/topics/news\"];\n```\n\n\n\n### Subscribe Device Tokens to Topics\n\n```js\nvar FCM = require('fcm-node');\nvar serverKey = 'YOURSERVERKEYHERE'; //put your server key here\nvar fcm = new FCM(serverKey);\n\nfcm.subscribeToTopic([ 'device_token_1', 'device_token_2' ], 'some_topic_name', (err, res) => {\n    assert.ifError(err);\n    assert.ok(res);\n    done();\n});\n```\n\n### Unsubscribe Device Tokens to Topics\n\n```js\nvar FCM = require('fcm-node');\nvar serverKey = 'YOURSERVERKEYHERE'; //put your server key here\nvar fcm = new FCM(serverKey);\n\nfcm.unsubscribeToTopic([ 'device_token_1', 'device_token_2' ], 'some_topic_name', (err, res) => {\n    assert.ifError(err);\n    assert.ok(res);\n    done();\n});\n\n```\n\n## Notes\n* See [FCM documentation][2] for general details.\n* See [Firebase Cloud Messaging HTTP Protocol][10] for details about the HTTP syntax used and JSON fields, notification and data objects. **(STRONGLY RECOMMENDED)**\n* On **iOS**, set **content_available** to **true** to receive data while your app is in background. (As seen in [FCM Docs][8])  \n\n## Credits\n\nExtended by [Leonardo Pereira (me)][3].\nBased on the great work on [fcm-push][7] by [Rasmunandar Rustam][4] cloned and modified from there, which in its turn, was cloned and modified from [Changshin Lee][5]'s [node-gcm][5]\n\n## License\n\n[MIT][6]\n\n[1]: http://github.com/isaacs/npm\n[2]: https://firebase.google.com/docs/cloud-messaging/server\n[3]: https://github.com/jlcvp\n[4]: mailto:nandar.rustam@gmail.com\n[5]: https://github.com/h2soft/node-gcm\n[6]: https://opensource.org/licenses/MIT\n[7]: https://github.com/nandarustam/fcm-push\n[8]: https://firebase.google.com/docs/cloud-messaging/concept-options\n[9]: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/APNsProviderAPI.html#//apple_ref/doc/uid/TP40008194-CH101-SW2\n[10]: https://firebase.google.com/docs/cloud-messaging/http-server-ref\n[11]: https://firebase.google.com/support/release-notes/admin/node\n[12]: https://firebase.google.com/docs/reference/admin/node/admin.messaging\n[13]: https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk\n[14]: https://developers.google.com/instance-id/reference/server#create_relationship_maps_for_app_instances\n[15]: https://github.com/sofiapm\n[16]: https://github.com/crackjack\n[17]: https://github.com/cesardmoro\n\n## Changelog\n1.5.2 - fixed bug whre send's callback were called twice - *Thanks to [@cesardmoro][17] for this fix*\n1.3.0 - Added proxy capabilities - *Thanks to [@crackjack][16] for this feature*\n1.2.0 - Added topic subscriptions management for web clients - *Thanks to [@sofiapm][15] for this feature*   \n1.1.0 - Support for the new firebase node.js sdk methods  \n1.0.14 - Added example file to quick tests <br />\n1.0.13 - Added a error response in case of TopicsMessageRateExceeded response <br />\n1.0.12 - Refactored the client removing the Event Emitter's Logic to fix concurrency issues. Using pure callbacks now also avoids memory leak in specific scenarios with lots of parallel calls to <b>send</b> function. <br />\n1.0.11 - \\<FIX\\> send function returning error objects when multicast messages (or individually targeted) returned both error and success keys on response message (even with error counter = 0 ) <br /> \n1.0.9 - Updated Documentation <br />\n1.0.8 - \\<FIX\\> 'icon' field no longer required in notification<br /> \n1.0.7 - renaming repository<br />\n1.0.6 - bugfix: send function was always returning an error object for multicast messages (multiple registration ids)<br />\n1.0.5 - bugfix with UTF-8 enconding and chunk-encoded transfers<br />\n1.0.1 - forked from fcm-push and extended to accept topic messages without errors<br />\n","readmeFilename":"README.md"}