Clearing conversations

Sunshine Conversations provides different approaches to clear the conversations depending on the stage of development you’re currently involved in. For production purposes, all messages can be completely deleted from a conversation using our API. For development usage, the conversation can be cleared by switching or logging out users on the client side (SDKs).


Automatic Message Deletion

The conversationRetentionSeconds app setting can be set in order to have conversations clear themselves automatically after a configurable period of inactivity.

Using the API

Messages can be immediately deleted by using the Delete All Messages API Endpoint. This endpoint removes all messages from Sunshine Conversations servers for a given appUser. Therefore, the conversation will be cleared across all of the SDK clients associated with the user.


curl $SMOOCH_ROOT/v1.1/apps/5963c0d619a30a2e00de36b8/appusers/c7f6e6d6c3a637261bd9656f/messages \
     -X DELETE \
     --user 'keyId:keySecret'
        appId: '5963c0d619a30a2e00de36b8',
        userId: 'c7f6e6d6c3a637261bd9656f'
    .then((response) => {
        // async code


For development usage only, some manipulations can be done on the SDKs to quickly clear a conversation.


On all Sunshine Conversations SDKs, logging in a user has the effect of attaching the current conversation to this given user. So, after that, logging out the user previously logging in will instantiate a new anonymous user (with a fresh conversation). Logging in a new user will have the same effect.

Here are the examples for each SDK:

Web Messenger SDK

  1. Open the console and login the current user

    Smooch.login("user-id", "your-user-jwt")

  2. Logout the user (or login a new user)



    Smooch.login("another-user-id", "jwt-2")


Create a button that is calling clearConversation to login and logout the current user.

// In viewDidLoad()
UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0 , 100, 100, 50)];
[button addTarget:self action:@selector(clearConversation) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Clear conversation" forState:UIControlStateNormal];
[self.view addSubview:button];

// After viewDidLoad()
    [Smooch login:@"user-id" jwt:@"your-user-jwt" completionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
        [Smooch logoutWithCompletionHandler:^(NSError * _Nullable error, NSDictionary * _Nullable userInfo) {
            [Smooch show];
// In viewDidLoad()
let button = UIButton(frame: CGRect(x: 0, y: 100, width: 100, height: 50))
button.setTitle("Clear conversation", for: .normal)
button.addTarget(self, action: #selector(clearConversation), for: .touchUpInside)

// After viewDidLoad()

func clearConversation(sender: UIButton!) {
    Smooch.login("user-id", jwt:"your-user-jwt") { ( error:Error? , userInfo:[AnyHashable : Any]?) in
        Smooch.logout { (error:Error? , userInfo:[AnyHashable : Any]?) in


Add a button in your layout with a button_logout id and add this code to your Fragment.

// In the onCreateView() method

Button mLogoutBtn = (Button) rootView.findViewById(;
mLogoutBtn.setOnClickListener(new View.OnClickListener()
    public void onClick(View v) {
        Smooch.login("user-id", "your-user-jwt", new SmoochCallback() {
            public void run(Response response) {
                Smooch.logout(new SmoochCallback() {
                    public void run(Response response) {

Deleting the cache

In a testing environment, erasing the cache can be a quick way to clear the conversation.

Web Messenger SDK

On the web, you can remove the session tokens for the current user.

  1. Open the JavaScript console on your browser.

  2. Navigate to the Application tab, Local Storage and finally the name of your website.

  3. Delete all the Sunshine Conversations key entries.

Web Messenger - Delete Keys


On iOS simulator, you can reset the data for the simulator. In the simulator, open the Hardware menu and choose Erase All Content And Settings.

iOS - Erase Data

Android SDK

On Android Studio, open the Android Virtual Device Manager from the Tools menu. Choose your emulator, press the arrow in the right side and choose wipe data.

Android - Wipe Data