Firebase component cannot do auto refresh

Hello,

I have a question regarding firebase implementation in mobile apps. I've followed the instruction in this post:

https://www.outsystems.com/forums/discussion/25871/how-to-configure-the-firebase-plugin/

And I've tried to implement the firebase plugin by downloading shoutsystems and in-app chat mobile for refrence. In Firebase component, there's a FirebaseReciever block where this is the component that recieve the information that was sent to specific TargetId. There are 3 event handlers in this component which are AlertEventRecieved, MissingData, and Ready. The MissingData and Ready events work perfectly but for AlertEventRecieved, it doesn't do anything even though I have already used FirebaseNotifyEvent with the same TargetId. To make it easier to understand, I've attached the .oml file.


What do you guys think that I missed in here?


Thank you so much.

Regards,


Hentry

If you haven't already, try running the app in the browser-based emulator, and see if there are any error messages in the browser tools' console that might help with what's happening. Could be as simple as a typo.

Hi Hentry,

Your problem is that you're sending the message to a different target than the one you're  listening to. 

Sending to:


And you're listening for messages on


Also you have a lot of warnings, always a good practice  avoiding them.

Cheers

Hello Andrew,

I've tried it in emulator and there's no error at all in the console. I've tried this several times from outsystems now, android apk with debug mode, and browser's emulator, but nothing's working.

Hello Henrique,

What you snipped is my old firebase block that I used in layout. For testing reason, I put the new firebase block inside my main screen that I used for sending a text input and its targetid is the same. Thank you.


EDIT:

I've changed the firebase block's targetId that you refer to in your post to be the same with targetId that I notify and still it doesnt work.


Regards,

Hentry

Solution

Hi Hentry,

I double checked your code, and you're right. It still doesn't work. The target needs to be the same though.

After I inspect the page, I noticed that you have javascript errors. Look at the following:

You probably have a miss-configuration on firebase.

I changed to some keys of my own and it works, so your code should be correct but your keys/configurations are the problem.

After a quick search this post seems to solve it, can you give it a try?

I also removed the block from the scree, there's no need to have the block loading twice (layout + screen)


Solution

Hello Henrique,

I've tried like you said and it works perfectly! And if I want to do this with more secure method, I should sign the user in to the database like the post that you gave me right? Where should I put the code that they gave in that post if I want to sign in the user to the database? Is it with javascript in login server action?

Thank you so much for your help sir! It means a lot!


Regards,

Hentry

Hi Hentry,

Glad that you were able to fix it :)

I never used it with the user authenticated against firebase db, I don't think there's anything pre-built for that. I know the configuration are DB rules that you can define on firebase -> databse tab -> rules.

Depending on what you're building you can use the firebase as a ping mechanism, you can write the messages on a table and then ping the device either with an Id or even blank, on the device when you receive the event refresh the query where you're retrieving your data from. In this way your sensitive data doesn't go through firebase. 


Hope it helps


Hello Henrique,

All that you said make perfect sense. I only need to use FireBase to refresh the query whenever we recieve something from another user. You help me a lot sir. Thank you so much.


Regards,

Hentry

Hi Hentry,

Glad that it worked out!

Cheers