12
Views
4
Comments
[Firebase Push Notifications] How to integrate FCM web push notification with Firebase Event notification
firebase-push-notifications
Reactive icon
Forge component by Shubham Agrawal
Application Type
Reactive

Hi, 

I'm trying to use Firebase as my notification source for both web push and in-app event notification. I was able to trigger the in-app event notification successfully and web push notification successfully when I used them independently. But when I tried to combine and use them together, I received an error stating my firebase had been initialized before. I tried to initialize them differently as Firebase1 and Firebase2 but still not able to work together. 

The above is the original code, although there is checking on the Firebase initialization, I'm not sure why it still initializes the second Firebase (not really familiar with JS and Firebase setup). 


This is from Firebase event notification forge. I tried to load Firebase Event Notification first prior to Web Push but it still doesn't work, not sure if they both work that way.. 

Any insight will be much appreciated. Thanks.


Regards,

Kenny

Hi @Yung Shin 

Please do not Initialize firebase twice. inittialize once and get firebase object inside event handler. i had already provided an event to get firebase object to use it in other places.

if still the problem persist, then please share the implementaion or exact error you are facing.


I hope it will help you.


Thanks & Regards

Shubham Agrawal

Hi Shubham, 

Thanks for replying. I'm receiving this error Assuming WebPush is being initialized prior to the Firebase Event, just noticed the FirebaseObj is being passed from the block. However, I'm not too sure how can I assign it for the Firebase Event's initialization The following is the Firebase initialization in the Firebase Forge. What I did now is to capture the Object from your block, and pass it into this block but unsure what is the next step. It also stated the registration has failed, upon checking the FCMToken is not stored as well.. 

Here is my implementation:
I place firebase event and web push side by side, not sure if it is possible for both of them to work side by side together. 

Hi @Yung Shin 

1) Why are you Initializing firebase second time. Please create event handler for vent which i have already provided. you will get firebase object in that handler. 

2) there is a service worker error. please add service worker js file in the location where that error is showing. you will get the service worker file in my forge component inside resources folder.


I hope it will help you.


Thanks & Regards

Shubham Agrawal

Hi Shubham,

1. How can I use your object as an object for another Firebase forge? 

The reason why I 'might' have to initialize twice is because both forges are consuming different input parameters from Firebase, where the Firebase by Labs require databaseURL and different API Key. For Firebase Push Notification, I take all the values from the 'config' instead. (Should I amend the structure for Firebase Push Notification to include the databaseURL to initialize together first?)

I'm new to Firebase and only able to follow step-by-step for each forge.. I removed the initializeApp in Firebase (by Labs) but still encounter the same error/warning for Firebase

2. After adding the service worker js file, I'm receiving this error instead 

Not sure if I missed something here.. 


Edit: After invalidated the cache through Site Properties, the above error for #2 is no longer persists. 

Kenny

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.