Xamarin iOS app not syncing with server


#1

I’ve got a Xamarin iOS test app I’m trying to get to work with Couchbase Mobile sync with CouchBase server. Everything works locally, but I can’t seem to get the data to sync to the server. I am using Couchbase Lite for .NET version 1.0.4.

I have a local instance of sync_gateway and couchbase server running on my Mac. Here’s the sync_gateway config file:

{
   "interface":":4984",
   "adminInterface":":4985",
   "log":["REST"],
   "databases":{
      "sync_gateway":{
         "server":"http://localhost:8091",
         "bucket":"sync_gateway",
         "sync":`function(doc) {channel(doc.channels);}`,
         "users": {"GUEST": {"disabled": false}
      }
      }
   }
}

Here’s the code snippet for creating sample test data, storing locally, and then pushing to server:

//create local data
Database db = Manager.SharedInstance.GetDatabase ("my-database");
var doc = db.CreateDocument ();
var vals =  new Dictionary<String,Object> {
	{ "text" , "value1" },
	{ "check" , false },
};
var result = doc.PutProperties (vals);

//sync with server
var url = new Uri ("http://localhost:4984/sync_gateway");
push = db.CreatePushReplication (url);
pull = db.CreatePullReplication (url);
push.Continuous = true;
pull.Continuous = true;
push.Changed += (object sender, ReplicationChangeEventArgs e) => {
	Console.WriteLine("Push Changed");
};

pull.Changed += (object sender, ReplicationChangeEventArgs e) => {
	Console.WriteLine("Pull Changed");
};

push.Start ();
pull.Start ();

What am I missing? When I go to the server to look like “sync_gateway” buckets, I don’t see the test data I just created. Instead, I see the following documents:

_sync:seq  2
_sync:syncdata { "Sync": "function(doc) {channel(doc.channels);}" }
 _sync:user: { "all_channels": { }, "sequence": 1, "rolesSince": { } }

#2

Can you try changing your users entry to this?

"users": {"GUEST": {"disabled": false, "admin_channels": ["*"]}},

#3

Yes, that seems to fix the issue.