QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
397 stars 358 forks source link

Users list not getting added to cache #820

Closed mrikh closed 7 years ago

mrikh commented 7 years ago

iOS - 10.3 Quickblox SDK - Latest taken using pod install

So i am requesting all the users using : QBRequest.users(for: page, successBlock: { (response, responsePage, users)}

and then checking if user exists in cache or not and adding them if he doesn't using:

    if QBRequestHandler.instance().usersService.usersMemoryStorage.user(withID: model.id) == nil{

           QBRequestHandler.instance().usersService.usersMemoryStorage.add(model)
    }

On printing the unsortedUsers() in usersMemoryStorage it prints all the users i just added successfully but when i restart the application, the number of elements are 0.

Logs for when fetching the list of users and adding them:


2017-06-11 14:27:57.233 quickbloxSample-Mayank[35696:4490171] [QBCore] Request URL:https://api.quickblox.com/users.json?page=1&per_page=100
2017-06-11 14:27:57.234 quickbloxSample-Mayank[35696:4490171] [QBCore] Request method: GET
2017-06-11 14:27:57.234 quickbloxSample-Mayank[35696:4490171] [QBCore] Request parameters:{
    page = 1;
    "per_page" = 100;
}
2017-06-11 14:27:57.235 quickbloxSample-Mayank[35696:4490171] [QBCore] Request headers: {
    "Accept-Language" = "en;q=1";
    "QB-OS" = "iOS 10.3";
    "QB-SDK" = "iOS 2.9.2";
    "QB-Token" = f28775c00802f3e1ece2d72fc37108ec2800e60a;
    "QuickBlox-REST-API-Version" = "0.1.1";
    "User-Agent" = "quickbloxSample-Mayank/1.0 (iPhone; iOS 10.3; Scale/2.00)";
}
2017-06-11 14:27:59.453 quickbloxSample-Mayank[35696:4490171] [QBCore] Response headers: {
    "Access-Control-Allow-Origin" = "*";
    "Cache-Control" = "max-age=0, private, must-revalidate";
    Connection = "keep-alive";
    "Content-Length" = 1180;
    "Content-Type" = "application/json; charset=utf-8";
    Date = "Sun, 11 Jun 2017 08:57:59 GMT";
    Etag = "W/\"861cb6c864825bd63676669be05bc37d\"";
    "QB-Token-ExpirationDate" = "2017-06-11 10:49:15 +0000";
    "QuickBlox-REST-API-Version" = "0.1.1";
    Server = "openresty/1.9.15.1";
    Status = "200 OK";
    "Strict-Transport-Security" = "max-age=31536000, max-age=15768000;";
    "X-Content-Type-Options" = nosniff;
    "X-Frame-Options" = SAMEORIGIN;
    "X-Request-Id" = "8b833b0a-9a72-4623-ab04-5ce95cc068c1";
    "X-Runtime" = "0.014817";
    "X-XSS-Protection" = "1; mode=block";
}
2017-06-11 14:27:59.454 quickbloxSample-Mayank[35696:4490171] [QBCore] Response object: {
    "current_page" = 1;
    items =     (
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T06:48:05Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28634502;
                "last_request_at" = "2017-06-11T08:38:25Z";
                login = mayanktesterone;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:38:25Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        },
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T06:49:10Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28634526;
                "last_request_at" = "2017-06-11T08:08:51Z";
                login = mayanktestertwo;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:08:51Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        },
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T08:09:59Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28635981;
                "last_request_at" = "2017-06-11T08:49:15Z";
                login = mayank;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:09:59Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        }
    );
    "per_page" = 100;
    "total_entries" = 3;
}
2017-06-11 14:27:59.458 quickbloxSample-Mayank[35696:4490171] [QBCore] Response object: {
    "current_page" = 1;
    items =     (
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T06:48:05Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28634502;
                "last_request_at" = "2017-06-11T08:38:25Z";
                login = mayanktesterone;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:38:25Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        },
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T06:49:10Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28634526;
                "last_request_at" = "2017-06-11T08:08:51Z";
                login = mayanktestertwo;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:08:51Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        },
                {
            user =             {
                "blob_id" = "<null>";
                "created_at" = "2017-06-11T08:09:59Z";
                "custom_data" = "<null>";
                email = "<null>";
                "external_user_id" = "<null>";
                "facebook_id" = "<null>";
                "full_name" = "<null>";
                id = 28635981;
                "last_request_at" = "2017-06-11T08:49:15Z";
                login = mayank;
                "owner_id" = 74814;
                phone = "<null>";
                "twitter_digits_id" = "<null>";
                "twitter_id" = "<null>";
                "updated_at" = "2017-06-11T08:09:59Z";
                "user_tags" = "<null>";
                website = "<null>";
            };
        }
    );
    "per_page" = 100;
    "total_entries" = 3;
}

On restarting the application i printed the users in in the cache in my dialogue listing and it comes out to be 0

Whenever i restart my application i'm signing in a user. For example everytime a user kills the app he has to sign in again. Is it possible that the cache is being cleared because of that?

ghost commented 7 years ago

Hi @mrikh, could you please enable QMServices logs and provide full logs again:

QBRequestHandler.enableLogging(true)
mrikh commented 7 years ago

Hi @Pro100Andrey. Feel free to mark this issue as closed as I am no longer using the caching ability for users so I don't have the code sample to reproduce this issue.