syncing firebase data over multiple users for a quiz app - flutter

I would like to make a quiz app that has a given time count down limit to give answers to a particular question. the app is intended to be used by many users all at the same time using the same time count down data, basically all users should be in sync with the same time limit to answer a question before moving to the next question. the question is how can i make this app using flutter and firebase? is firebase capable of doing this?

Yes, you can use firestore to do this.
Firestore can support at most 1 million realtime connections at the same time. So usually you don't need to worry about the network limitation.
For the time count down, you probably need to consider about the delay of network. Instead of syncing the count down time every moment, you can sync the start time and the end time with the server, then let the app count down the time locally.

Related

How long device will keep data if It does not come online

I like the idea of Firestore persistence.
If a write is done on Flutter Application to a Collection, but application has no internet access. I understand that it will be written to firestore when device comes back online.
My question is, what about if device comes online after 30 days or 1 year. The document says temporary network interruptions , how much temporary ?
Does the write ever gets aborted ? Suppose device comes online after 2 years, will it write the pending data?
Does the write ever gets aborted?
No. Not until the device or app storage is cleared for whatever reason.
Suppose device comes online after 2 years, will it write the pending data?
Yes.

In FireStore how to know if client is listening to particular document

I have the following scenario.
Sensor generates data every 30 seconds.
Update sensor data on FireStore document.
Mobile app shows the sensor data in realtime.
One problem with above steps is that lot of data writes takes place, which increases billing. I want to optimize it by changing step 2.
Update sensor data on FireStore document only if mobile app is listening to realtime updates
To do this optimisation I need a way to know if app is listening to realtime update. So is there a FireStore event/callback fired when app starts/stops to listen to realtime update.
There's nothing built into Firestore for this.
Two options that come to mind:
Use the presence solution that is documented for Firestore, which uses Firebase's Realtime Database under the hood. This gives you a way to track what users are connect to the database.
Build something yourself based on Firestore alone, for example by having each mobile app periodically writing a server timestamp into a known document, and then reading the most recent timestamp from the sensors and determining if that was recent enough to send updates.

IOS alert in background

My question is very simple but unfortunately I don't find any answer around the Internet. I have an app alerts the user you amount is due based on invoice date in the database. The problem is how can I check periodically while the app in the background. I tried beginBackgroundTaskWithName but it expires after max 10 munites and also I tried back ground fetch but it doesn't work in proper time manner, so may be it takes a day to fetch again.
I really need your help in this.
Thanks in advance

How can an iOS app run a function in the background in a recurring manner (i.e. once an hour)?

On devices which support multitasking, I'd like my iOS app to run a function in the 'background' when the app is not running (i.e. it's suspended). I know that iOS supports running tasks in the background, but I'm not sure how to make the function recurring (and only when the app is not in the background). What's the best approach?
I'm not interested in running a long-term function in the background but a short-term function to simply update the application badge #. However this number is dynamically based on the app's data, and needs to run a query against core data.
To further clarify, yes, my core data will not be changing, but the badge represents a number of items due. As time progresses, more items will be due, so I want to update the badge to show the proper items due as time progresses. So if 5 items are due now, but half an hour later 3 more items are due, then by the time the next hour comes around, 8 items will be due even though the core data has not changed at all in and of itself.
It can't, the only task allowed to run in background are: audio, voip and location.
Why do you need to update the badge data every hour if the data stored within Core Data is not changing? ie. the app isn't running?
You can do this using push notifications, like previously posted, or you can use a scheduled local notification based on the data when the app is closed or backgrounded. I think those are pretty well your only options.

Ensuring correct date/time

we are creating a location-enabled app where users use this app to record certain events in the field.
The important part of the event data is when an event happened. This is no issue when user is online, but we also support situations when user is offline (by remembering & later syncing events).
There could be situations when users are offline and they change the time on the phone, so that event times are wrongly recorded.
So, what would be the best way to ensure we get a correct time, independent of user actions, given that device could be offline. Some ideas:
GPS time. Is it possible to acquire it?
Tracking system time changes made by user?
Any other idea?
Note: time does need second accuracy, approximately minute accuracy would be ok.
Note2: we are creating mobile apps for Android and iPhone, so I'm interested for generic solutions and also solutions that are specific to any of those two platforms.
I, personally, wouldn't worry so much about this scenario. The liklihood of someone intentionally changing the time on their Android (which periodically throughout the day syncs to a time server automatically) while offline seems low to me. That being said, the only way I could see compensating for this is to keep a service running in the background that keeps a running tally of the seconds passed since recording the location data offline. Once uploaded to your servers you could use the elapsed seconds to calculate a time offset from current UTC time. It's an awful lot to go through, but it would work.
GPS time is an interesting idea, but Android allows users of the SDK to send mock locations to their devices. I'm not sure you could reliably track changes to system time either, and even if you could you'd be capturing them after the fact without the current real time as context.
We use GPS times in our app for very similar reasons. Since our users are in different time zones and we want local times, we define from our server what time zone they are in at installation time (they don't move very far). Hadn't thought of the mock GPS locations, but you would need to be a fairly advanced user to do that.