Mesibo auto delete all messages after a period of time

37 views Asked by At

Is there a way/line of code that you can insert in Android Studio project to auto delete all messages in the android app that are older than let's say 7 days?

I would like to have all messages canceled/deleted after 7 days of when they where seen/read.

Thank you!

1

There are 1 answers

0
mesibo On

You can use the Mesibo.deleteMessagesOlderThan() API and pass the number of seconds to delete messages older than. To delete messages older than 7 days (604800 seconds), use:

Mesibo.deleteMessagesOlderThan(604800);

You would want to call this when the app loads or periodically in a background service, for example,

public class MyApp extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    
    // Delete messages older than 7 days
    Mesibo.deleteMessagesOlderThan(604800); 
  }

}

This will automatically clean up older messages without any additional coding.

For older mesibo API versions, you can use Mesibo.deleteMessages(ts) instead and pass the timestamp from 7 days ago.

Refer to the https://docs.mesibo.com/api/messaging/deleting-and-recalling-messages/

You may also use disappearing messages if desired

https://docs.mesibo.com/api/messaging/disappearing-messages/