Hasan Toufiq Ahamed
Hasan Toufiq Ahamed

Reputation: 13

Firebase Realtime Database auto increase value

Is it possible to auto increment a value of firebase realtime database. without running app.

That means, let a user have point, and that point is stored in firebase realtime database. I want this point will auto increase also when the app will closed. Is it possible?

Upvotes: 1

Views: 463

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 600131

There is nothing built into the Firebase Realtime Database to auto-change values at specific times.

But Firebase has an integration with Cloud Functions, that can be used to trigger (small) bits of JavaScript code in conditions you define. One common use-case that developers use Cloud Functions for is to implement code that runs on a certain time, or at certain intervals. For more on this use-case, see Cloud Functions for Firebase trigger on time?

Upvotes: 1

PradyumanDixit
PradyumanDixit

Reputation: 2375

From your explanation this seems to be an issue which can be easily solved by keeping the app running in background. For this purpose look here.

Quoting the answer from above link I gave here,

A very simple answer for your problem is to use Service. It will allow you to perform variety of tasks while being in background and is your best bet for sending your location/data to server silently.

Also read this answer for help.

Although both the answers are related to location update but they can be easily extended to fulfill your requirements.

Hint: The above quoted answers are sending the data to a server at frequent intervals. Send your data to Firebase server when the data-field is changed.

Upvotes: 1

Related Questions