CloudKit: CKOperations don't run when app is suspended

201 views Asked by At

I am listening to remote notifications from CKSubscriptions from a CloudKit public database. I want to handle the case where I receive the notifications while the app is suspended ... I simulate this on my device by running the app using Xcode with the "Wait for executable to be launched" option. I notice that the application:didReceiveRemoteNotification:fetchCompletionHandler delegate method is called correctly, and I queue up a CKFetchNotificationChangesOperation operation after this, but the operation is never run. I don't get any of the notificationChangedBlock or fetchNotificationChangesCompletionBlock callbacks. The same works fine if the app is running in the foreground and a notification comes in.

I have tried setting the QoS on both the CKOperation and the operation queue to NSQualityOfServiceUserInteractive but that doesn't seem to help either.

I am also trying this on WiFi, with the iPhone plugged into my computer at 100% charge.

Is there anything else I need to look into to get the CKOperations to run in the background?

1

There are 1 answers

0
malhal On

I would guess you are calling the fetch completion handler too soon which suspends the app. You need to call it at the end of all your operations.