0

I am creating an android app where I wish to add certain feature like Google Duo app. Using that feature where the user can specify the amount of time the message will be available on server.

I am using Firebase Real-time Database as backened. But as of now, I haven't succeeded in creating such a thing by using only Android client and Firebase which solves the purpose and is also valid solution.

Can somebody tell me whether Firebase provides such TTL(Time to live) functionality for data. If not then what will be the best way to create such feature?

Any help or info will be highly appreciated.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • 2
    See http://stackoverflow.com/questions/38447748/firebase-realtime-database-entries-expiration/38447949#38447949 – Frank van Puffelen Sep 25 '16 at 22:41
  • But you can easily build it with a tiny script, such as this: http://stackoverflow.com/questions/37501870/how-to-delete-firebase-data-after-n-days/37504961#37504961 – Frank van Puffelen Sep 26 '16 at 02:36
  • @FrankvanPuffelen this is extremely helpful thank you so much. I think this will solve one part of puzzle **but what about deleting the rest items automatically from database so that I don't have unnecessary outdated data building up ?** Will I have to manually call .removeValue() on every child that doesn't fall under required **cutoff** ? – Sahil Sharma Sep 26 '16 at 17:03
  • The code in the linked answer removes the outdates items. – Frank van Puffelen Sep 26 '16 at 17:29
  • @FrankvanPuffelen I was so excited to actually see a great solution that I completely missed what you wrote in onDataChange(). Sorry about that I was thinking what I saw will just query data based on **cutoff** range. Will try not to comment in a hurry without properly understanding full answer. Thank you once again :) – Sahil Sharma Sep 26 '16 at 19:03

1 Answers1

1

I think currently Firebase doesn't provide such functionality. But it will surely be quite interesting if they do.

Other than that I think that you can create something similar using a custom app server. Such that it stores the time stamp of those messages and listens for value changes. When the target time is reached, you can simply delete that data or (set the value to null). This should give you desired results if executed properly.

Firebase provides you great Server-sdk. You can use one for java (as it will be in sync with your app as well).

Kamal Das
  • 147
  • 1
  • 9