2014-10-30 13:03:45.539 OnePlan[15930:501055] Pull Status: 1
2014-10-30 13:03:45.539 OnePlan[15930:501055] Push Status: 3
2014-10-30 13:03:45.540 OnePlan[15930:501055] SYNC progress: 0 / 0
2014-10-30 13:03:45.540 OnePlan[15930:501055] Pull Status: 3
2014-10-30 13:03:45.540 OnePlan[15930:501055] Push Status: 3
2014-10-30 13:03:45.540 OnePlan[15930:501055] SYNC progress: 0 / 0
2014-10-30 13:03:57.553 OnePlan[15930:501055] Pull Status: 2
2014-10-30 13:03:57.553 OnePlan[15930:501055] Push Status: 3
2014-10-30 13:03:57.553 OnePlan[15930:501055] SYNC progress: 0 / 0
2014-10-30 13:03:57.553 OnePlan[15930:501055] Pull Status: 2
2014-10-30 13:03:57.554 OnePlan[15930:501055] Push Status: 2
-(void)replicationProgress:(NSNotification *)notification
{
NSLog(@"Pull Status: %u", app.user.syncManager.pull.status);
NSLog(@"Push Status: %u", app.user.syncManager.push.status);
if (app.user.syncManager.pull.status == kCBLReplicationActive || app.user.syncManager.push.status == kCBLReplicationActive)
{
// Sync is active -- aggregate the progress of both replications and compute a fraction:
unsigned completed = app.user.syncManager.pull.completedChangesCount + app.user.syncManager.push.completedChangesCount;
unsigned total = app.user.syncManager.pull.changesCount + app.user.syncManager.push.changesCount;
NSLog(@"SYNC progress: %u / %u", completed, total);
// Update the progress bar, avoiding divide-by-zero exceptions:
self.progressBar.hidden = NO;
self.progressBar.progress = (completed / (float) MAX(total, 1u));
}
else if (app.user.syncManager.pull.status == kCBLReplicationOffline || app.user.syncManager.push.status == kCBLReplicationOffline)
{
self.progressBar.hidden = YES;
self.progressBarView.hidden = YES;
self.failureView.hidden = NO;
NSError *error = app.user.syncManager.pull.lastError ? app.user.syncManager.pull.lastError : app.user.syncManager.push.lastError;
if (error != self.syncError)
{
self.syncError = error;
if (error)
{
self.failureLabel.text = [error.userInfo objectForKey:@"NSLocalizedDescription"];
}
}
}
else if (app.user.syncManager.pull.status == kCBLReplicationIdle || app.user.syncManager.push.status == kCBLReplicationIdle)
{
[app.user setInitialSyncStatus:YES];
[self initiateApp];
}
}
From the documentation:
- Stopped: A one-shot replication goes into this state after all documents have been transferred or a fatal error occurs. (Continuous replications never stop.)
- Offline: The remote server is not reachable. Most often this happens because there's no network connection, but it can also occur if the server's inside an intranet or home network but the device isn't. (The replication will monitor the network state and will try to connect when the server becomes reachable.)
- Idle: Indicates that a continuous replication has "caught up" and transferred all documents, but is monitoring the source database for future changes.
- Active: The replication is actively working, either transferring documents or determining what needs to be transferred.
On Oct 30, 2014, at 1:12 PM, Christoph Berlin <hoptoawe...@gmail.com> wrote:I would expect that the status stays OFFLINE (1) the whole time unless I am missing something
- if that is the case could someone tell me what I miss? How would I implement a function that makes sure that the app doesn't continue without the successful sync.