Not able to read as well as write data in firebase database - firebase

I am using firebase cloud server to save the data of the user when using a mobile device via expo. The information is not getting saved(or read) in the firebase database. But on using firebase functions like
firebase.auth().createUserWithEmailAndPassword(email, password);
the data gets stored in the Authentication tab of firebase console.
createNewUser: (userData) => {
return firebase
.firestore()
.collection("users")
.doc(`${userData.uid}`)
.set(userData);
}
But on the running this(the code above) the information of the user is not getting saved in the firebase database.
I tried the same running on the web browser and it works just fine(storing data on database as well as on the authentication tab) but not on mobile devices. My friend has the same code and it works fine for him.
After many attempts i came to a realization that on using mobile devices, my server is not able to send information to the firebase cloud service. this is the snapshot of the no of request firebase cloud service got. The snapshot shows that it has not received an requests which is not true I have sent it many requests.
I get an error saying
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.
(Saw setTimeout with duration 3299524ms)
But the same error is being shown on my friends device so i don't think that the possible reason for the issue is this.
Can anyone tell what could be the possible issue here, please. THANK YOU

Related

Flutter StreamBuilder shows Firebase data even when I'm offline

This is not a problematic question, it was asked because just wanted to know what's actually going on behind it, I can't find an answer in any documentation.
When i open the app without internet it shows the data from firebase, i try to restart then it also shows, i try to clear the cache but it shows the data like it shows from the local database, Why is this happening, is there a built-in local storage or something in Firebase Flutter?
Firestore SDKs cache any data that they've recently seen, as well as any pending writes from the local client that haven't been synchronized to the server yet. On mobile clients (iOS and Android) this cache is enabled by default, while on web you can enable it with an API call.
For more on this, see the Firebase documentation on accessing Firestore data while you're offline.

Flutter Firebase no notification shown on terminated app

I am using Firebase cloud messaging for flutter. Everything works as expected, when the app is either open or in the background. But if I close the app (terminated) no messages are received.
I send the messages with the firebase console.
I have tried two emulators, that both had play services installed.I even logged in with a google account in the emulator.
Any ideas what I might be doing wrong?
I set priority to high and it started working. The docs only talk about priority high in the context of data messages but it seems it is important for notifications as well then.

Flutter notifications

I'm using firebase as database. Flutter responds when any changes are made in cloud while using app, but will is respond the changes even when the app is in background or killed?
Second: is it possible to create notifications within the flutter app without using Firebase notification feature? Like a new document is added in database and app is suppose to create notification using some specific lib from pubdev.
When the user is not actively using the app, the OS (Android or iOS) allows a very limited amount of network activity from that app. For this reason you'll typically stop receiving updates from Firebase once the app is backgrounded, and you won't receive any updates as soon as it's killed.
If you want to show updates to the user when they're not using the app, that typically takes using Firebase Cloud Messaging. With this scenario you:
Set up custom server-side code that listens to the database. This code can run on your own server, but also for example on Cloud Functions.
When this code detects a change to the data, it sends a message to the relevant user(s) through Firebase Cloud Messaging.
This requires that the app registers itself either in your database (with its FCM token) or for a certain FCM topic to receive updates about.
For more on this, see the Firebase documentation on Cloud Messaging, Cloud Functions, my answer here and the FlutterFire docs.

Will my firebase cloud messaging API still work after my realtime database has been deactivated?

I received an e-mail from firebase-noreply #google.com to the tune of:
[Firebase] Your unused Realtime Database ‘my secret’ will be deactivated in 14 day(s)
We've detected the following issue(s) with your security rules:
any logged-in user can read your entire database
any logged-in user can write to your entire database
I have an app on my Raspberry Pi which is available by web, that will send a firebase message to my mobile phone. It will enable a user (any friend of mine that I chose to tell the url to) to track my position. The webpage on my Rpi contains the API key.
Following this e-mail, should I still expect my app to work?
It's a while since I wrote the app but I do find it occasionally useful. The link that firebase sent me to edit my security settings doesn't work. I think I only had an entry in the firebase realtime database to enable me to get an API key. Please forgive me if I am asking a daft question but it has been years since I worked on this.
firebaser here
The email is specific to the Firebase Realtime Database of your project, and won't affect Firebase Cloud Messaging in any way. If calls to FCM succeed before the database is disabled, they will continue to succeed after the database is disabled.
Of course, if your app needs to interact with the database to do its work, that will stop to function when the database is disabled.

Why does Firebase Realtime db work in incognito, etc but not Firebase Cloud Messaging

I'm just getting started with the Firebase ecosystem and doing some investigating before committing to a GCloud database implementation (Datastore vs. Firestore). My target client is Web/browser and my backend services will be in AppEngine.
Tinkering with the cloud messaging quickstart example, it seems that FCM doesn't work in several scenarios (incognito mode, Safari, if permission blocked). However, the friendly chat demo that uses realtime db updates does appear to work in these scenarios.
High level could anyone explain why?
My goal is to subscribe to events for the client to update state, etc without the use of polling. It seems overkill to put these into firestore just to bypass the notifications permission requirements. Any insight is appreciated. These events could be dispatched from several different backend services and are not exclusively bound to db records.
Update
For what I wanted to do, I was able to simply use Firestore and had no needs that targeted specific devices that merited using FCM. Firestore came out of beta since I posted this question and works well for live subscribing to queries that update local state, which is ultimately what I needed to do.
The FCM client works on the promise that it can identify your browser, even when the page is not open. So it needs to persistently be able to identify the browser. It uses an Instance Token for that, which I assume it persists in the local storage of your browser. And since an incognito window has its own local storage, it becomes a separate instance ID.
The Firebase Realtime Database itself does not persist any information about the instance. Instead you pass in all the necessary information when you initialize the FirebaseApp instance, and then get a DatabaseReference. Since the incognito window runs the same code, it's accessing the same information in the database, and thus seeing the same result.
Note that this would be different if you use Firebase Authentication in combination with the Realtime Database. Auth will persist the user token to local storage, so that won't be shared with the incognito window.

Resources