AddListener with Dispatch Queues not working when app goes background in Couchbase Mobile Lite (iOS Swift)

I am using Couchbase Mobile V2.1.2 in iOS Swift Languages. I am showing progress like how much data pull from server to lcoal db. So when a user goes to background why data synching seems data is pausing and when i app enter foreground app resumes the synch. I used dispatch Queues also.

I enabled allowReplicatingInBackground to true, please correct me, if i did anything wrong in threading, i searched in Cocuchbase Mobile samples. i didn’t find any for addListener with Didspatch queues.

Here is the my code snippet.

func startReplicator(type: ReplicatorType) {
    let url = URL(string: AppURLs.kCouchbaseURL)!
    let target = URLEndpoint(url: url)
    let config = ReplicatorConfiguration(database: database!, target: target)
    config.replicatorType = type
    config.allowReplicatingInBackground = true
    Print.print("Store ID \(StoreDetails.shared.storeID ?? "No Store ID")")
    if let storeid = StoreDetails.shared.storeID{
       config.channels = [storeid]
    config.continuous = true
    config.authenticator = BasicAuthenticator(username: CBConstants.kUsername, password: CBConstants.kPassword)
    self.replicator = Replicator(config: config)

    //Database.setLogLevel(.error, domain: .replicator)
    let concurrentQueue = DispatchQueue(label: "testQueue", qos: .background)
    listener_token = self.replicator?.addChangeListener(withQueue: concurrentQueue, { [weak self] (change) in
        guard let strongSelf = self else { return }
        concurrentQueue.async {
            Print.print("------------ QUEUE")
        if let error = change.status.error as NSError? {
            Print.print("--------- Error code :: \(error.code) and des \(error.debugDescription) and status is \(change.status.activity)")


            let s = change.status
            Print.print("------- PushPull Replicator: \(s.progress.completed)/\(, error: \(String(describing: s.error)), activity = \(s.activity) and replicator \(change.replicator.config.replicatorType)")

@pasin or @jens Can someone look at my issue. Please provide a sample document or something which is related to addChangeListener with Dispatch Queue.

Even my couch base sync gateway returns sometimes 2 records and sometimes 4 records. I haven’t get any help from anyone. Really we need help as we are beginners and we moved from SQL database to Couchbase

Here is the other post link