Hey,
I would like to ask when we should call completion handler for didReceiveIncomingPushWithPayload delegate method if we have some async code fired inside.
Let's have following examples:
(completion called already in same runloop cycle)
private let provider: CXProvider
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
/// code to get call info
provider.reportNewIncomingCall(with: uuid, update: update) { error in
/// some code here
}
completion()
}
(completion called at "future" when we "finish" handling voip notification, potentially future runloop cycle)
private let provider: CXProvider
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
/// code to get call info
provider.reportNewIncomingCall(with: uuid, update: update) { error in
/// some code here
completion()
}
}
(error cases in both examples were omitted but i'm aware I should handle them too)
Which one is more correct?