how to achieve push Notifications without using firebase Cloud functions? - flutter

my APP Is Really Depends on push Notifications, for examples iF the app has two actors, owner, and user, if the owner posts something, the user must be notified, based on their locations and Engagement in the app, which means the System first searches the nearest user and notify him, Notification is performed based on the location of the user, the user who is found in the nearest location is notified first, so What I want to ask you is, is it possible to achieve this without using firebase Cloud functions, Since firebase Cloud functions are NOT Free at this time. it asks me Billing account but the payment method is not available in my country

Apologies for my previous reply, I misunderstood the situation,
Also another solution besides one signal, you can use FCM on your own server, via FirebaseAdmin SDK. If you have a NodeJS server, a simple one, you can perform all firebase functions on it. In the end, it's not an absolute necessity to use cloud functions, it's just more convenient for a simple task or a few functions than spinning up your own server just for notifications. I would advise to go with this solution, and you will have access to cloud firestore via the admin SDK, you'll feel right at home.
Firebase cloud functions requires billing info, but you aren't charged. You have 2 MILLION free api calls per month. Then every extra 1 million calls cost less than half a dollar.
Do you know what 2 Million API invocations per month means? That's 32 THOUSAND API calls per day. If your app is generating that much traffic, trust me, you will not be worrying about these costs.
You can use OneSignal if you want, but it's more work for you, and it's outside the Firebase ecosystem.
Go with cloud functions, when you are reaching the limit of the free tier of 2Million monthly API requests, you can start looking for investors in your app.

Related

Flutter – question about architecture, providers and fetching data from server

I am a rather fresh Flutter programmer so please excuse any flaws in the questions below…
I am struggling with a structural/ architecture dilemma. Here is the background:
App rationale:
my app allows its users to check little jobs available in their area and if they find time and are in a proper location to execute the job for a remuneration,
the app uses standard REST API (not Firebase) so that the server cannot be relied on sending status change notifications to trigger re-fetching of data,
the critical elements are (1) up-to date list of jobs for a given address - other user may have already taken on a job in an address (timed refresh of list e.g. every 5 mins), and (2) the app needs to keep track of the user’s location and accordingly ask the server for jobs if the user relocates by more than 2km in less than the refresh time,
The challenge:
I guess that on the basic level the app should have the following providers: (1) auth – providing the authToken, (2) geolocation – regularly checking user’s location, (3) jobList - for particular location (fetches high level job descriptions and addresses(, (4) jobDetails – fetches exact instructions for carrying a particular job,
as you can see: (2) geolocation and (3) jobList – need to refresh programmatically (at interval or on some change of geolocation), while (1) auth, (4) jobDetails are triggered by the user.
The Big Question ;) is … what is the proper architecture for the above type of app? More specifically:
should I use services for connecting to the server API and these would in turn be used by the providers?
how to ensure programmatic refetch of jobList on timer and relocation event from geolocation?
how to continually listen to location changes to detect a relocation but not overwhelming the app with processing?
should I store the (quickly outdating) jobLIst data just in its object class or should I use settings provider or a local db or maybe there is an easy way of storing the latest JSON response not to have to build the settings provider or db mapping?
in all my call to Auth api I need to provide the deviceId - how to make it available accross the app - this is pretty static but is needed in authentication so should checking it be a part of the auth provider?
If you could comment on the above or suggest a source of relevant examples I would be really grateful.
Thanks and cheers!
Here are my thoughts:
how to continually listen to location changes to detect a relocation but not overwhelming the app with processing?
You can rely on third party to do this for you. Such as: geolocator. With this, you can specify the amount of distance the user must have moved before the package notifies you of the change in user location.
should I store the (quickly outdating) jobLIst data just in its object class or ...
Since it is likely for a job listing app to use this data often and in various places, I would prefer to use db. It would be helpful in the long run too, if you plan to have some sort of analytics done on the mobile end or to gather any insights.
in all my call to Auth api I need to provide the deviceId - how to make it available accross the app ...
When you app is initialized, you could fetch the deviceID and store it in shared_preferences. Then in auth api, you could just retrieve it before making the API call.
should I use services for connecting to the server API and these would in turn be used by the providers?
As for geo location, geolocator can update you about the change in location and you could make an API call based on that.
However, if you plan to have a timer based approach to refresh your job listing, then you must realize that your users are likely to face issues arising from your inconsistent data. If you have plans to tackle it, then this implementation here might help. But I strongly feel that server supporting push notifications or maybe a web socket approach would be ideal here.

how to create backgroud service in flutter

how to create a background service in FLUTTER
with posh notification
I create an app but I went to integer a service to check the database when the app is not run
thank tou
I would recommend using Google Cloud Scheduler, which allows you to create CRON jobs which can send a request to your API, on a regular basis. The first three jobs are free.
If you also need to implement the actual function checking your database, have a look at Google Cloud Functions. Those can be written in Javascript or Typescript and call make calls to external APIs as long as you are on Blaze Plan (which includes the monthly free quotas).
The advantages are:
you get free credit when you create your account
depending on your needs you might not need more than the free monthly quota for Google Functions calls (first 2 millions invocations are free every month)
it's very easy to create a scheduled function which will picked up and run by the Cloud Scheduler
it's highly scalable and reliable so you don't have to worry about managing your own servers

Using Firebase Firestore with mobile clients directly is secure enough? How can I avoid malicious requests and excessive requests exceeding limits?

I have some concerns about using Firestore directly from mobile clients. I saw that with Firestore, mobile app is controls to db directly. There is only db side control is rules. However I am not yet understand how can I resolve my concerns. I worrying because with decompiling app or any other ways maybe someone can access maliciously.
To resolve my concerns and improve the security I want to:
Limit access per time for user. For example if some one writes or
reads db 30 second ago I want to block their access until 1 minute.
Especially it is important for writing.
I want to have the only document owner write their documents and
block others to write. For do this I don't want to store owner id in
same document because if I put this information to there, readers can
receive this information and maybe some way they can write request
with this information.
In summary, I want to prevent malicious and excessive requests exceeding limits. I want to avoid the risks in db side. How can I resolve my concerns in the two above matter?
Scenerio:
Think that there is harmful someone with name X. X knows how to
decompile mobile app or maybe knows how to request my application's
firebase Firestore account (maybe watched communication I don't know).
X wants to harm my application. First X watching communication and if
we give owner userid in document X receives needed information so
sending request with changing his/her userid or auth.uuid. Secondly X wants to
disable firebase of my application. For do this X sends too much
requests. The limit is overs due to too many requests. Note that: I am
using Firestore directly with mobile application. There is no web
service to communicate.
How can avoid this scenario?

Cant apply for next level rate limit Facebook marketing api

I have to create script to create adsets and ads for a facebook campaign and I have to do it for a lot of items. For now, i can create every needed entity but there is a big problem, the rate limit. I reach it pretty quick (I can create like 15 items before getting a rate limit exception) and this is very limitating, creating eveything by hand is actually much faster... I want to apply to the next level of rate limitation but I can't. One of my coworker contacted someone from facebook and we were told we did not make any API call using my app ID. Since I am able to create a campaigns, adsets, ads... and we can see those in power editor I don't understand what is going on.
What my dashboard looks like
We will need to be able to create everything using the API really soon so, after some research, I try asking the question here. Did I miss something when creating my app ?
You probably want to go through the official request to promote your app from a Basic level to a Standard level. The level for your app determines how heavily it is rate limited. Details here: https://developers.facebook.com/docs/marketing-api/access
It sounds as if you have not make your official request in app dashboard. It's possible we evaluated your number of API calls before you reached the threshold, or the data we are able to see on your API calls was from an earlier time period when you did not consistently reach the boundary.
You could also be hitting rate limits due to your error rates.
You can apply here, and if needed, reapply: https://www.facebook.com/business/standardadsapi?attachment_canonical_url=https%3A%2F%2Fwww.facebook.com%2Fbusiness%2Fstandardadsapi

Realtime backend platform for reporting / dashboards?

I will build a dashboard system for my apps, where a page will have several widgets that draw charts, tables and glyphs representing potentially unrelated data.
The client will be HTML5 and I can push for only modern web browser.
My big problem is what backend use for this. I want to store "tables" for use in the charts and in real-time update the widgets.
For example, a invoicing widget will show how much $$ have been collected today. In the "table" will have a row for each total of the invoice:
inv = 1; total = 50
Total: 50
and the widget will draw that. When new data is pushed:
inv = 2; total = 100
Total: 150
The widget will show in realtime the total to the end-user.
The data is private for the user company. Eventually I will need to purge too old data (ie: I only need to keep as much data is necessary to proper evaluation of the info need for the end-user. For example, only keep 1 month of invoicing totals).
I'm thinking in use something like http://www.firebase.com/ or http://pusher.com/ but I suspect only solve the "notify in realtime" part of the equation. As far as I understand, they not let me get past data (ie: If the data is update in the weekend and the user open his dashboard to see what happened)
Then I see http://derbyjs.com/ and the possibility to use mongodb.
I wonder which backend/platform will bring me closer to the build of this system. I have experience with python/django/.net/postgress but could accept the use of something else if solve best this kind of app behavior.
Firebase offers both the "notify in relatime" part that you mention, as well as persistent data storage. Take a look at the tutorial, which walks you through building a real-time persisted chat app (the past chat messages are stored in Firebase and are sent back to the client every time you reload). And you can do much more complicated stuff like the real-time charts / widgets that you mention as well.
The big limitation with Firebase right now is that we're in closed beta and the data is currently unprotected (anybody can read and write your data). The security features are coming soon though.
Some other backend platforms you may want to evaluate are: Meteor and Simperium. Firebase and Simperium are cloud services where your data is stored in the cloud and you don't have to manage any servers of your own, while Meteor and DerbyJS are platforms that you have to install and run on your own server.
I would recommend signalR. It's amazing and you can literally do anything with it. Check it out: www.signalr.net and if you have any problems simply go to www.jabbr.net You will find a very helpful community there. I implemented a notification mechanism similar to facebook together with real time monitoring and a small chat in the same web site.