jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

Multiple instances of FCM #45

Closed mihristov closed 5 years ago

mihristov commented 5 years ago

Hi. I have two mobile apps managed by a nodejs server which is responsible for sending notifications to both apps. Since each mobile app has it's own Firebase account, my nodejs server needs to keep two instances of FCM simultaneously. Current behavior: Version: "fcm-node": "1.4.1" When I start the nodejs server I get the following message:

Error: The default Firebase app already exists. This means you called initializeApp() more than once without providing an app name as the second argument. In most cases you only need to call initializeApp() once. But if you do want to initialize multiple apps, pass a second argument to initializeApp() to give each app a unique name. at FirebaseAppError.FirebaseError [as constructor] (/usr/src/app/node_modules/firebase-admin/lib/utils/error.js:42:28) at FirebaseAppError.PrefixedFirebaseError [as constructor] (/usr/src/app/node_modules/firebase-admin/lib/utils/error.js:88:28) at new FirebaseAppError (/usr/src/app/node_modules/firebase-admin/lib/utils/error.js:122:28) at FirebaseNamespaceInternals.initializeApp (/usr/src/app/node_modules/firebase-admin/lib/firebase-namespace.js:68:23) at FirebaseNamespace.initializeApp (/usr/src/app/node_modules/firebase-admin/lib/firebase-namespace.js:392:30) at new FCM (/usr/src/app/node_modules/fcm-node/lib/fcm.js:159:23)

Can I request a change (a second parameter to the FCM constructor) so that I can start using the lib? Reference: https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp

jlcvp commented 5 years ago

Thanks for your contribution, I'll update the package to version 1.5.0