Code: Select all
Killing app because it never posted an incoming call
to the system after receiving a PushKit VoIP push.
Code: Select all
var backgroundTaskID: UIBackgroundTaskIdentifier = .invalid
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
// Start a background task to extend execution time
backgroundTaskID = UIApplication.shared.beginBackgroundTask(withName: "HandleVoIPPush") {
// End task if time expires
UIApplication.shared.endBackgroundTask(self.backgroundTaskID)
self.backgroundTaskID = .invalid
}
// Start your async task
asyncTask { _ in
provider.reportNewIncomingCall(with: callUUID, update: update) { _ in }
// End the background task
UIApplication.shared.endBackgroundTask(self.backgroundTaskID)
self.backgroundTaskID = .invalid
// Call the completion handler to let the system know you're done
completion()
}
}