Document info not pulled in GrocerySync sample app


I have been working with “GrocerySync” sample iOS app for two way data sync test. But, it doesn’t pull document from server (the documents those i updated through “Postman” using REST API to server), iOS app shows a progress bar during the sync and log shows “SYNC progress: 0 / 1” “SYNC progress: 1 / 1”, but the document info not getting updated in the UI table view. Could you please help me how the new server documents can be synced/updated back to “GrocerySync” sample iOS app UI table view?

Hi @jongladwin,

We can’t really help without more specific information. From what you’re written, the document is syncing to the app, so it’s just a matter of figuring out why the UI isn’t updating. You could put in logging statements in the code that retrieves new documents and adds them to the list to see where it’s failing as a start.

Thanks for the reply.

The GrocerySync sample iOS app does have the following code,

  • (void) replicationProgress: (NSNotificationCenter*)n {
    if (_pull.status == kCBLReplicationActive || _push.status == kCBLReplicationActive) {
    // Sync is active – aggregate the progress of both replications and compute a fraction:
    unsigned completed = _pull.completedChangesCount + _push.completedChangesCount;
    unsigned total = _pull.changesCount+ _push.changesCount;
    NSLog(@“SYNC progress: %u / %u”, completed, total);
    // Update the progress bar, avoiding divide-by-zero exceptions:
    [self.rootViewController showSyncStatus: (completed / (float)MAX(total, 1u))];
    } else {
    // Sync is idle – hide the progress bar and show the config button:
    NSLog(@“SYNC idle”);
    [self.rootViewController hideSyncStatus];
// Check for any change in error status and display new errors:
NSError* error = _pull.lastError ? _pull.lastError : _push.lastError;
if (error != _syncError) {
    _syncError = error;
    if (error) {
        [self showAlert: @"Error syncing" error: error fatal: NO];


It has only to Updating the progress bar and showing the count. I don’t know if there is any API to get the document info itself and looking for help on that.


  1. Please provide specifics on the document that you updated on the server (The JSON structure)
  2. Confirm that the document structure in (1) matches the document structure expected in the Grocery Sync App. As mentioned in a related post - Savings issue with JSON , if you change the structure of the document, you will have to update the app accordingly so it displays correctly



  1. How to get the document info? I am not getting it still. Could you please advise me some API or sample code, how to pull document through iOS Obj-C app?
    The sample code i got so far is, just to update the sync status, not anything specifically retrieving the document and update on UITableview.
  2. Another question, when the server gets new document from Postman using REST Api, on the mobile app side, Do I need to manually insert document into the local db? how the replication works actually?

If you are using the Grocery Sync sample app, it will pull the document and display it. Again, my previous question- 1) What is the PUT request with body that you used to create the document on server?

I have attached the reference screenshot…

iOS code:

// Create the new document’s properties:
NSDictionary *document = @{@“text”: text,
@“check”: @NO,
@“User”: @“iOS”,
@“Member”: @“Test”,
@“created_at”: [CBLJSON JSONObjectWithDate: [NSDate date]]};

// Save the document:
CBLDocument* doc = [database createDocument];
NSError* error;

if (![doc putProperties: document error: &error]) {}

As you can see i didn’t change the JSON structure on the Postman tool when sending, the same as what uses in sample iOS App.

The issue is, when I update the existing record (document) or add new document from iOS Grocery sample app, it’s getting updated on the server side. Similarly, the document which are created using iOS app, is being updated on the server side, getting updated back on the iOS app as well.
But when I create new document for the same DB using Postman tool and sending to server. Server is getting updated with that new document, but it’s NOT updated on the iOS app.

Couple of things to look into ;

  1. created_at needs to be specified in the right format when creating from Postman. It should be ISO-8601. Example is : 2017-05-01T17:39:03.679Z
  2. are you sure the database that you are using is the same on the Postman Client and your iOS App? According to screenshot, the postman client is updating the “travel-sample” database. Is that what you have setup on your couchbase Lite?

Excellent! After correcting created_at date format, it worked as expected.

Glad to know things are working now.

Could you please explain the limit 20 MB on the server side? What does that mean exactly? it can’t store documents more than 20 MB on the server? or just one document limit is 20 MB?

Can you please close this thread if the original question in this thread was resolved and start a new thread with your new question