[Firebase Mobile] NewNotification event not always firing (fix attached)
Question
firebase-mobile
Mobile icon
Forge component by David Sousa
Application Type
Mobile

Hi team,

We faced an intermittent issue with the FirebaseCloudMessaging block. The NewNotification event would not always fire after you navigate to another screen.

We figured the problem out. As it turns out, the JavaScript in the OnReady event of that block opens a semaphor using a global window variable called firebaseScopeActive, which is then set to false in the OnDestroy event.

The problem with this is that, because this is a globally accessible variable, when we click on a link to navigate to another screen, there is a transition effect / animation that fires the OnReady event of the new screen before firing the OnDestroy event of the previous screen that we are navigating away from, which results in having firebaseScopeActive = false, effectively disabling any kind of notification callback from the block.

The solution was simple, we simply did away with window.firebaseScopeActive and worked with a local variable. That way we isolated the semaphor feature within each individual screen instead of having multiple screens interacting with the same global variable, preventing conflicts like the one we faced.

I've attached the full OAP with the fix based on the latest version of the component. I also sent a team joining request in case you prefer that I upload this version to Forge myself.

Thanks!

Firebase Mobile.oap

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