I'm using to replicate on a background thread.
[manager backgroundTellDatabaseNamed:databaseLocal to:^(CBLDatabase *bgdb)
{
NSLog(@"Starting pull on background thread...");
// Inside this block we can't use `db`; instead use the instance given (`bgdb`)
[self startPull:bgdb
withRemoteUrl:remoteUrl
withRemoteUser:remoteUser
withRemotePassword:remotePassword
withEvents:events
withOptions:options];
// Required in order to listen to events
[[NSRunLoop currentRunLoop] run];
}];
`startPull` contains:
CBLReplication* pull = [db createPullReplication: url];//...
[pulls setObject:pull forKey:db.name];
// Add the events handler.
if (events) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleReplicationEvent:) name:kCBLReplicationChangeNotification object:pull];
}
[pull start];
(Full code is here)
The notifications work fine when the method is called from outside the backgroundTellDatabaseNamed block. I add the `[[NSRunLoop currentRunLoop] run]` line but that does not seem to have got it working.
Anything I've missed or need to consider to get notifications when replicating in the backgroundTellDatabaseNamed block?