Couchbase Mobile handle pending changes from Server


#1

Is there a way to find out if there is changes pending to be synced on mobile device by channel? We do not want to sync automatically but prompt the user to synchronize. But would like a way to notify the user that a sync is pending for a particular channel. Also would like to know the last date and time stamp of the content in cblite db by channel. We are syncing content by channel and at a given point of time there can be multiple channels on the local device. So a way to identify what channels are on the local device and date and time the last doc was received in that channel and eventually a way purge documents by channel.


#2

The mobile devices don’t know anything about channels; that information is kept only within the gateway.

If you know the logic for what documents are in what channels, you can create a view on the client matching that logic to see what docs are in it.

The client API doesn’t currently have a way to find out what documents are “unpushed”. There’s an implementation on a branch, but it’s not in a release yet.


#3

Oh wait, are you asking about pulling changes from the Gateway? I thought you were asking about pending local changes to push.

To look for pending incoming changes you can send a request to the Gateway’s REST API — the _changes operation is what you need. This is the same call the replicator makes to find out what revisions to pull. It’s not lightweight (on the server side, though.)


#4

More likely, though, you’d want to set up push notifications. The details are platform specific, but you need a server-side component that watches changes and pings the OS vendor’s push notification server as necessary to send notifications to devices.


#5

Thanks for the question. We talked more about your use case, and I think there is room for a feature to make this easier. I’ve filed the feature request here. Please comment on it if you think we need to capture more details.

I’ll discuss with some engineers here the right way to find the information you need now, via the Sync Gateway REST API.