Cloudkit very slow response with: fetchUserRecordIDWithCompletionHandler

Hello,


I am getting really really slow response times with fetchUserRecordIDWithCompletionHandler It takes 10 seconds+ to fetch the user record id sometimes even a full minute or longer. A simple request like that can't take that long. And a few times it took only a few seconds...

(this is a big problem since the user has to wait a long time, since the id is directly needed in the app)


I presume it has something to do with the priority of the operation since cloudkit works asynchronously. Maybe there's someway to change this like you can do with a CKOperation by changing queuePriority.


Right now I am testing with this simple code, to make sure it works still the slow response times are there. Of course my xcode project is bigger but this code gets called directly in the view did load method as the first thing.


CKContainer.defaultContainer().fetchUserRecordIDWithCompletionHandler({ (userRecordId: CKRecordID!, error:NSError!) -> Void in
        println(userRecordId)
})

I have looked at other answers around slowness of cloudkit but most of them only say to wrap UI code in


dispatch_async(dispatch_get_main_queue()) { }


inside the completion block. But doesn't really make a difference (Sorry for any language mistakes, not native...)

Thanks in advance!


Replies

As a suggestion, You can use "CKFetchRecordsOperation.fetchCurrentUserRecordOperation()" instead to get current user recordID.

And you can change the queuePriority with CKFetchRecordsOperation. The response seams faster.

It is better to use 'qualityOfService' rather than 'queuePriority' for the queue priority nowadays.