Is there a recommended way to handle an iOS app resigning active state / 
entering the background (e.g., pressing the Home button) during a large 
replication (e.g., pulling 1,000s of documents)? 

CBLReplication.h says "On iOS a replication will suspend itself when the 
app goes into the background, and resume when the app is re-activated." But 
this does not seem to happen with our app running on iOS 7. According to 
the log, the replicator keeps pulling documents from the server even while 
the app is no longer active and it's in the background. In my testing, it 
seems to keep going for at least 8 minutes. According to Xcode it's using 
30-50% CPU while in the background on WiFi, which might not be what the 
user is expecting.

Looking through the CBL iOS source code, it looks like the comment in 
CBLReplication.h has been superseded and there is now support 
in CBL_Replicator+Backgrounding.m to handle background replication on iOS. 
I see the"APP BACKGROUNDING" in the log, so I'm assuming that's enabling 
replication to continue running in the background.

I added my own code to our app delegate applicationWillResignActive method 
to stop all of the replications by invoking CBLReplication stop. [I tried 
setting CBLReplication.suspended = YES instead of invoking stop, but the 
replication continued to run (probably because of the backgrounding code 
resetting suspended).] However, invoking stop sometimes results in the 
following error:

WARNING*** : CBL_Puller[https:...]: Unable to save remote checkpoint: Error 
Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. 
(NSURLErrorDomain error -999.)"

Thanks very much.

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/77e56e66-5e85-48a1-811f-296db3b872da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to