Asynchrone Aufgabe nach „didReceiveIncomingPushWithPayload“ und vor reportNewIncomingCallIOS

Programmierung für iOS
Guest
 Asynchrone Aufgabe nach „didReceiveIncomingPushWithPayload“ und vor reportNewIncomingCall

Post by Guest »

Wenn ich eine PushKit-Benachrichtigung erhalte, muss ich sofort CXProvider().reportNewIncomingCall aufrufen, sonst wird die App mit der folgenden Meldung beendet.

Code: Select all

Killing app because it never posted an incoming call
to the system after receiving a PushKit VoIP push.
Gibt es eine Möglichkeit, eine asynchrone Aufgabe zu starten, nachdem ich eine Benachrichtigung erhalten habe, und CXProvider().reportNewIncomingCall aufzurufen, wenn die asynchrone Aufgabe abgeschlossen ist? Ich habe versucht, die Hintergrundaufgabe zu verwenden, um zu verhindern, dass die App beendet wird, aber es hat nicht funktioniert. Folgendes habe ich versucht:

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()
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post