smartnav / fcm-notification

Push notificaton for ios and android
24 stars 13 forks source link

Firebase App already exists #5

Open alighafoorzade opened 5 years ago

alighafoorzade commented 5 years ago

i'm using this package in adonis js and i use the code below:

const FCM = require('fcm-notification'); class NotificationController { async send({request,response}){ const data = request.only(['api_key', 'login_tokens', 'title','body']); let login_tokens = data.login_tokens; let fcm_tokens = new Array(); login_tokens.forEach(async function(login_token){ fcm_token = await Notification.findBy('login_token',login_token); fcm_tokens.push(fcm_token); }); let message = { notification:{ title : data.title, body : data.body } } const fcm = new FCM('./private-key.json'); return fcm; fcm.sendMultipleToken(message,fcm_tokens,function(err,response){ if(err){ console.log('err:\n',err); }else{ console.log('response:\n',response); } }); } } ` and i receive below 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.

relu-xz commented 5 years ago

@alighafoorzade There is a pending PR:

4

dobrevnikolay commented 5 years ago

The issue seems to be still present