I’m not sure if my observer is the problem as it is being triggered, but progress is still zero (0
). I already tried two notifications as found in forums.
// Class property
private(set) var pull: CBLReplication!
let cblReplicationChange: Notification.Name
// Notificaiton test#1
self.pull = self.database.createPullReplication(kSyncGatewayUrl)
NotificationCenter.default.addObserver(self, selector: #selector(self.pullProgress), name: self.cblReplicationChange, object: self.pull)
NotificationCenter.default.post(name: self.cblReplicationChange, object: self.pull)
// Notificaiton test#2
NotificationCenter.default.addObserver(self, selector: #selector(Sync.pullProgress(_:)), name: NSNotification.Name.cblReplicationChange, object: self.pull)
Both tested notifications above are being triggered, but progress is still 0
.
In pullProgress(), i print to xcode console the following:
pull.changesCount // this is still 0
pull.completedChangesCount // this is still 0
Sync log:
Initial log once Sync is triggered
CBLReplication[from http://dev.db.suites.digital:4984/sync/]: offline, progress = 0 / 0, err: (null)
Then after the initial log, I print to xcode console the changesCount and completedChangesCount, value is 0
.
Then eventually printed in xcode console
CBLReplication[from http://dev.db.suites.digital:4984/sync/]: active, progress = 0 / 0, err: (null)
CBLReplication[from http://dev.db.suites.digital:4984/sync/]: active, progress = 0 / 5, err: (null)
CBLReplication[from http://dev.db.suites.digital:4984/sync/]: idle, progress = 5 / 5, err: (null)
While the above logs are being printed to console, changesCount and completedChangesCount were only called or printed once.
Not sure if this is connected…
When user is unauthorized, the error does not also print the expected result.
let pullLastError: NSError? = self.pull?.lastError as? NSError
print(pullLastError?.code) // result is nil
print(pullLastError?.localizedDescription) // result is nil
Although I can see the sync log CBLHTTP[401, <http...
Kindly help. Thanks!