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 48 forks source link

I had a solution for a bug (app was already initialized) #72

Closed mianmuri1991 closed 3 years ago

mianmuri1991 commented 3 years ago

Hi, when you send two or more requests by using fcm-node in a .js script there is an error that says that the app already exists.

In the node_modules/fcm-node there is a file called fcm.js

My solution is to edit this file, like this (I had already done this and it works):

else{ //accountkey object passed, new SDK 'de-promisefy' use <--- STAYS THE SAME if(firebaseadmin.apps[0]){ firebaseadmin.apps[0].delete() } firebaseadmin.initializeApp({ credential: firebaseadmin.credential.cert(accountKey) }); this.send = function(payload, _callback){ <--- STAYS THE SAME