Does Google Firebase charge for inactive user accounts? [closed] - firebase

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 10 months ago.
Improve this question
Consider an app which allows users to cancel their subscription but which keeps the user data stored on Google Firebase. That is, the user is not actually deleted from Firebase, but he's just flagged as inactive. If the user later on decides to activate his subscription again, this app just removes the inactive flag from the user, and restores everything the user had access to until he had cancelled his subscription.
This means of course Firebase would have to maintain the user's data forever, even though some users may never came back again. Or at least the data would have to be kept for say one year or so, which would be a grace period in which the user would have the chance to come back and still have his data available in the app.
My question is: would Google charge for this inactive user data during the time the user is inactive? Or does it charge only for active users?

Firebase is 18+ products, so it really helps if you are explicit about which specific data in which specific product you're asking about.
On Firebase Authentication there is no charge for inactive users, nor a charge for active users. The only charge is for signing in with a phone number (above the free quota), but that won't apply to inactive users.
Cloud Firestore has no concept of active or inactive users. It does however charge for the data that you store in it, and for read/write/delete operations you perform on it, and for the bandwidth that is consumed while reading data. If you store user data in Firestore, you will always pay for the storage of that data, even during periods when the data is not accessed.
For more on this, see the Firebase pricing page, which is quite complete on what products are charged and how.

Related

Firebase - bidirectional communication between users in a 2 player game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
It seems like there are two choices with firebase for sending and receiving "moves" between players in a 'serverless' two player game. I could either use FCM and firebase cloud functions to send and send receive messages between the players,
i.e. player 1 calls a cloud function to communicate a "move" and the function calls FCM to send a message to the opponent a "move" was initiated by the other player.
or I could have both players observe the "game state" document in firestore, so that each player calls a cloud function to update the game state, and the other player is notified about the opponents move when the observer of the "game state" document registers a change in the document.
Neither of these approaches seems ideal fo the purpose, using the game state document seems a little easier perhaps could be because I understand firestore better than FCM.
just wondering what the "best practice" is for handling this kind of bilateral signalling between two users. (I guess the same basic question would arise in trying to build a "chat function" between two users on an web app. (the app itself is built in Angular) and just uses local code, a few cloud functions and a firestore, but no dedicated server.
If you want to use Firebase for this I would recommend to use the realtimedatabase. The FCM can have some lag when delivering and it depends on multiple stuff you can't control like battery status, etc. (the OS decidec more when to get new messages). By using the realtime database you are in control when it happens. I would not use Firestore because you are charged there for reads and writes and you will probably have a lot of them.

how to implement in app purchase for app on play store in Flutter and Firebase? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am developing app which uses ticket system and users can buy consumable tickets to spend and The ticket data should be saved in firebase firestore into user document so how to implement it?
can I use 3rd party packages like Razorpay or Square ?but by Playstore rules the transaction should be via google play billing api as they take 30% cut!?
all I want to do is when user buy some tickets and transaction is completed then their ticket quantity in firebase firestore should increase so that when the use it I can decrement that value from Firestore.
In case when you sell real tickets for some events, you can use third-party acquiring like Stripe or Square and avoid 30% Google commission.
But if you are selling virtual goods or services (including some virtual tickets in your app) you must use Google in-app purchases. Otherwise, your app might be removed from the store.
You can check our service, which makes it easy to implement in-app purchases and subscriptions. It provides simple methods so you don't have to deal with Google Billing or Apple Storekit directly.
Here is a quick start guide

How to authorize certain pages to different users in flutter [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
We got assigned to make event-management (Creating College Events with Firebase) application in flutter. Work we did: Creating Event (form) and returning an event card (containing event details in brief) in Homescreen. But we were told to make different pages for certain users like admin and student coordinators who can only create an event. While users can view event only. With the help of what can we do this?
Is there any library in flutter which we are unaware of?
Do we have to make another layout for admins and another for coordinator and other for users and then connect them?
You can give different levels of authorization to different people.
Maintain a users collection in your Firebase database
For each user, create a document. You might already be storing details like name, uid, email, etc. In addition to that, maintain a string field level.
Upon login, check user's level. For instance, if the level==student you can display on your homepage only the button that will lead to event_list_page.dart.
If level==admin, also display a button tocreate_event_page.dart.
How will you assign the level?
If there are only a handful (5-6) admins, manually edit their tag in Firebase console.
(Assuming email auth) Otherwise, you will have to create a list of email ids of admins, in advance. Then you can simply run a script using Firebase Admin SDK to fetch the user documents of admins from your users collection in database.
If you don't want to use Firebase Admin SDK, you can also write some code in Flutter itself to fetch admin documents and update their tag.

Should Firebase listeners be removed when a Native app is "backgrounded"? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
It's considered good practice to remove listeners from Firebase databases (whether that be Cloud Firestore or Realtime Database) when the listening components are unmounted.
In a lot of applications, mine included (React Native app), this might not happen very often.
For example, when my user is authenticated (signed in), they are subscribed to a number of listeners on both RTDB and CFS. Things like notifications and messages and other "realtime" updates i want them to see app-wide - think notification "badges" for example or "unread messages".
Developers of Native applications will know that apps can remain "backgrounded" for long periods of time. And with auth refreshing, users will rarely log out of my application. This means that those components are never (or rarely) unmounted and thus, remain subscribed to updates - i think.
Should i be adding logic that removes those subscribers to realtime data when a user backgrounds the application, only to re-instate them when they foreground again?
What you're asking is primarily a matter of opinion, which is off-topic for Stack Overflow. That said, you should probably take some time to understand the ramifications of leaving listeners added indefinitely.
A listener that's not removed when the user isn't looking at your app still incurs the cost of downloading updates to the documents it's listening to. Whether or not that's acceptable is entirely up to you.
The host OS will likely throttle the network access of app that can't be seen by the user after some time. This is for the benefit of the user, so poorly implemented apps don't consume excess network and battery. You can't depend on these listeners to work properly when this happens. If you want listeners to stay active while the app isn't visible, you will need to tell the host OS what you want using whatever APIs it provides. Even then, you don't have any guarantees, as the OS may simply kill an invisible app in order to reclaims resources.
You will have to decide for yourself when it makes sense add and remove listeners, after you understand the behavior apps on the given OS.

When does it make sense to use Firebase realtime DB and Firestore together? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Is there any situation where it makes sense to use both realtime and firestore in conjunction? What situations lend themselves more favorably to firebase realtime vs firestore, or a combination? I keep reading about horror stories of people getting hit with huge costs is there anyway to test before hand.
For context I am looking to work with an auction based market place of over 50,000 products. The idea is to be able to filter those products as needed, create, modify and delete bids for those products, favorite items and retrieve Users bids. From what I was reading the general suggestion (to keep cost low) for market places using firebase seems to suggest storing products in realtime db and the user objects, sales etc. in firestore. Kinds of queries I will need are find products with the lowest/highest bids, most favorited items, as well as fetching users current and purchases.
When would it be optimal to store in realtime vs firestore, from a cost perspective?
My current logic is to store the product objects in realtime since they will be referenced more frequently. Alternatively I am thinking it makes sense to store the user info, their bids, and purchases in one document in a firestore as that would incur just one read cost, and for a highly active user could result in a large amount of data to be transferred. Where I am confused comes with things like viewing the previous sales of a given product vs getting a user's previous sales, should sales be stored in realtime (as their own object or embedded in the product object) or firestore (embedded in the User doc) or both?
Looking at your app that you plan to make, let have a short talk regarding it.
A bidding app, first someone wants to sell their stuff so they post it in your app. Then every single user of your app may see it start bidding on it. Now as I don't know how your app is going to work but here's my assumption you will store the data of bidders and the bids they make in firebase realtime database.
This will involve lots of read, write operations. Now Firestore does offer you 20K operations/day, but if you cross the limit it will barely cost you $0.18/100K writes and $0.06/100K reads. Now the choice entirely depends on scale of your app. If your app has large number of audience, go for Realtime-Database. You can download upto 10GB of data per month for free and a dollar per GB beyond that. But this has a catch, if you stick to the spark plan, you can have only 100 simultaneous connections to the database so I doubt the performance if you have large number of users. It can go upto 200K using Blaze plan and that too per database. So if you create another database you will have more. I will personally suggest create multiple databases as per the region or any parameter to spread the traffic. [Again it's upto how many people use your app]
In my opinion, you should use the Firebase Realtime database your app. [Make sure you utilize the firebase storage as well for storing large photos of the things on sale].
Lastly, use firestore when you have less number of operations but are larger in size. Use firebase realtime database when you have many small tasks like updating the highest bid value or number of users currently bidding for a particular thing, use Realtime DB.
In my opinion, go for realtime database. I too use it for some game stuff like to store user stats and update it as the user progresses. This involves lots of read/write/update/delete operations so I stick with realtime-database.
When to use Firestore along with the real-time database?
As you have mentioned user profile, I will suggest use Firestore to store those credentials. Because user's won't generally update their profile so this won't cost much writes. Also the bidders would be much interest in bidding rather than watching others profiles. So even if if a few users check other's profile. This won't cost you much reads. But even if your app is designed in such a way that bidder must check seller's profile once, then firestore will definitely help you reduce usage of realtime database's [GB Downloaded] quota.
Every time someone queries data from your realtime database, you consume some part of the 10 GB of free download limit.
Also as I have mentioned the simultaneous connections to the database, if you host user profile data in Firestore then firestore will take care of profile visits so that bidders get faster response from your application. Just make sure you utilise all the free quotas from firebase storage, firestore and the realtime database and make sure your app is designed in such a way that it spreads traffic evenly between all services. Use the cloud functions on your back-end, and don't make your application [.apk] too heavy on client side as the app needs a lot to code.
So the conclusion, use firestore to store data which won't be accessed frequently like the user credentials and whatever stuff they have on sell. Use realtime database to store bidding data. Oh and yes, if you also want to store some stats like how many purchases has someone made or some information that changes too frequently put that in firebase realtime database. You can simply create a child node users/${username} and keep the frequent stuff in realtime database. This won't cost you much storage but take of that download limit. Shouldn't be expensive much especially talking of your app is going to address 50000 products XD.
I am looking to work with an auction based market place of over 50,000 products.
If you have comparatively less number of users, realtime database is sufficient but who knows when there may be a huge rise in your app users. So it's better to spread the data in both Firestore and Real-time database as mentioned above.
Just a caution: This is what I faced, then searched over stackoverflow and found this. Firestore counts READS even if you are just scrolling over the data tab in firestore. So make sure you don't just get surfing over there. I made 2 writes and was just looking at how the data is being stored and I already got 27 reads ...

Resources