kCBLReplicationChangeNotification in iOS works only once

42 views
Skip to first unread message

Raj Shekhar

unread,
Jun 21, 2016, 11:34:16 AM6/21/16
to Couchbase Mobile
Hello I am unable to observe and monitor replication..Pull replication is working fine I got all the documents but could not observe replication through kCBLReplicationChangeNotification.  I have used your code from your documentation. I am using latest CBLITE 1.2.1. I am using all code in main thread.The replication function is called only once when I start my app.Here is my code :

    NSURL* newRemoteURL = [NSURL URLWithString:syncUrl];

    

    if (newRemoteURL) {

        _pull = [database createPullReplication:newRemoteURL];

        CBLReplication *push  = [database createPushReplication:newRemoteURL];

        NSNotificationCenter* nctr = [NSNotificationCenter defaultCenter];

        [nctr addObserver:self selector: @selector(replicationProgress1:)

                     name: kCBLReplicationChangeNotification object: _pull];


         _pull.continuous = YES;

        if (!kSyncGatewayWebSocketSupport) {

            _pull.customProperties = @{@"websocket": @NO,@"normal": @YES};

        }

       [_pull start];

         }

    

     - (void)replicationProgress1:(NSNotification*)n

       {

           Bool active = (_pull.status == kCBLReplicationActive)

       }


I have tried everything but couldnt succeed .Please help me out as I need to call my function when replication stops.   

Jens Alfke

unread,
Jun 25, 2016, 5:20:06 PM6/25/16
to mobile-c...@googlegroups.com
Your code looks fine. Are you sure that the notification method isn’t being called, i.e. have you set a breakpoint in it?
The only other possibility I can think of is that the object that runs the code you showed is getting dealloced soon afterwards.

—Jens

Raj Shekhar

unread,
Jun 27, 2016, 5:22:27 AM6/27/16
to Couchbase Mobile
Thanks Jens for the quick response .I have set breakpoints and logs notification method isn't being called .I have also checked that object are not deallocated.I have no clue why this is happening.Can you please reproduce this at your end or suggest me alternate way to check when synching gets stopped.

Jens Alfke

unread,
Jun 27, 2016, 10:51:43 AM6/27/16
to mobile-c...@googlegroups.com
Sorry, I can’t debug your application for you. What I’d suggest doing next is turning on logging and enabling the “Sync” logging channel. This will log the replication progress. In particular, you’ll see messages of the form
CBLReplication[…]: …, progress = …/…
That message is logged immediately before the kCBLReplicationChangeNotification is posted.

—Jens
Reply all
Reply to author
Forward
0 new messages