How to restrict premium features of app in flutter? - firebase

In a flutter app using firebase back end, how can the premium features of the app be restricted?
For example if the user haven't paid for subscription then only allow 10 chats per month, or something like this.

You have to add in-app purchases to your Flutter app, follow this codelabs to implement it..
There are three main types of in-app purchases:
Consumables: Can be purchased multiple times.
Non-consumables: Can be purchased once but never again.
Subscriptions: Gives users access to purchase for a limited amount of time.

Use custom claims and enforce it with security rules.
Once a user has paid, or unlocks premium features in whatever way you see fit, then that user can get a custom claim associated with the users account in firebase. This can be checked for in frontend as well in backend.
More details and great examples at:
https://firebase.google.com/docs/auth/admin/custom-claims

Related

BuildFire: Tracking Commerce and Conversion Analytics

I am attempting to track certain events in Buildfire's platform and have a few questions. I've integrated Firebase into a plugin not using the Buildfire API but by following Firebase's steps to integrating with a web app.
I'd like to be able to register the following events but don't see them mentioned in the Buildfire Wiki:
When a user signs up (creates an account) on an app - I believe Firebase registers users anonymously the first time they use an app since Firebase has been integrated but was wondering if there was a signup event when a user actually creates an account to distinguish between people who view the app and those who create an account
Paywall view (when a user tries to see premium content and is directed to the paywall).
When a user subscribes to a paid plan - additionally, I'd like to access the subscription information such as the price of the subscription.
These events would help drive funnels and deliver better conversion rate statistics. I've looked but just haven't found the documentation related to tracking these events within Buildfire. I've looked at the getUser methods under Authentication in Buildfire's API but don't see any user information returned regarding subscriptions.
Any information would be appreciated!
There are many ways to accomplish what you are looking for. I'll try to describe several so you can pick the method that best suits you.
Use the BuildFire integration with Firebase. This doesn't really change much on your implementation. However, you now will have the BuildFire Auth Servers sending your Firebase server, secure user information along with User Tags. If you have the user tagged when they view premium content, then you can run queries on this directly in firebase.
https://github.com/BuildFire/sdk/wiki/Buildfire-Firebase-Integration
Send your Analytics to BuildFire. This way you have one spot to view the users' journey
https://github.com/BuildFire/sdk/wiki/How-to-capture-Analytics-for-your-plugin
For more advanced analytics and funnel creation you can send your analytics to BuildFire and use BuildFire's integration with Segment.io which will allow you to pipe the data into your database, google analytics, mixpanel, or anyone of the hundreds of integrations they have.
https://learn.buildfire.com/en/articles/3225298-how-to-integrate-segment-with-your-app-for-additional-analytics

Firebase Calendars

I have been searching all over for this, and I just haven't been able to find a clear answer to my questions.
I'm developing an app for a client and using Firebase as my backend (it's my first time). I need each user account to have it's own calendar.
I will be using the Firebase O-Auth but I don't want my app to see or edit a users auth account calendar (ie: if a google user logs in I don't want to edit their google calendar). I want our database to store a unique calendar for each unique user.
Will the calendar API allow me to do this? The app could potentially have thousands of calendars. I've seen some docs about limits, but it seems like limits on api calls, which I don't have any estimates for at this time.
Would a service account be appropriate for this application?
I've checked these other posts, but they don't quite answer my questions:
How to create a scalable calendar service backend for an Android app?
Google Calendar API - Designed for?
Any kind of insight would be much appreciated. Thanks!
Generally what we do in this case is create calendars using documents and collections within Firebase. Here is an example of a calendar app that uses Firebase to store its appointments. It is written in Flutter, but the backend design for Firebase should be easy to understand.
https://www.syncfusion.com/kb/12067/how-to-work-with-the-firebase-database-and-the-flutter-calendar-for-appointments

Firebase Dynamic Link: Increase Custom Domain Limit

I've started using Firebase Dynamic Link to replace Google Short URL service. I see it allows only 5 custom domains per account. Is this limitation due to a free account that I'm using? Can I register more than 5 domain if I upgraded to a paid plan? Though, as per my best knowledge, Firebase Dynamic Link is a free product and doesn't have anything like paid plans.
I could not find this limitation documented anywhere in official site.
To know more about this limitation, I submitted a ticket to firebase support. As per reply, Yes, it's possible to increase the limit. You have to submit a ticket at https://firebase.google.com/support/contact/ with detailing the use case.
It seems they have not made this public but they can increase limit when requesting for selected Firebase Console projects.

Is it possible to see how many users are authenticated by google, facebook, twitter or anonymous signed-up from Firebase Console?

In realtime database I have exactly 448101 users that authenticated by different providers. Is there any easy way to filter how many users sign-up with facebook, twitter, google or anonymous-login? I believe this feature should be in the analytics section of firebase console.
Thanks
There is no such feature in the Firebase Console at the moment. But it sounds reasonable, so I suggest you file a feature request.
In the meantime: since you say you have the users in the database, you might be able to derive the data from there, or at least start tracking it there.

Authorization and charging flow with Shopify

I am developing an addon for Shopify platform and using the Shopify NET library I have managed to authorize the user shop and gather some data.
Now I need to charge the usage of the Addon with a monthly fee (providing 7 days trial) but I cannot figure out the flow I must follow.
I guess that I have to call Recurring Application Charge API after the user authenticates (at the callback from the authorization URL) and if the user declines the charge then I have to log him out. Is that correct?
Do I have to care for providing 7 days trial by myself or the Shopify RACharge API with manage it by itself?
What do I have to do when the user cancel the subscription or freeze it?
Can anyone point me out a document that analyze the charging flow except the Shopify Billing API which is not that helpful after all?
First question, you're right. You either have to log out the user or you just let him authed without permission to see some views or all of them.
There's a propperty on Recurring Application which allows you to define the days of the trial: "Number of days that the customer is eligible for a free trial.", so Shopify handles this for you.
When user cancels a subscription or his store is put on "frozen" status, you should make sure he doesn't have access to your App functionalities, though if it's frozen, he won't even be able to log into his store.

Resources