By using one of the sample video calling app provided by Twilio (VideoCallKitQuickStart), I am trying to trigger an incoming call by sending a VoIP notification to the App. But the App doesn't trigger an incoming call. I also tried keeping the App opened while sending a VoIP notification and the App crashes, by throwing the below exception
NSInvalidArgumentException: Attempt to insert non-property list object 'PKPushPayload: 0x16e44af0' for key payload
Could someone, please help me or point me in the right direction on how to trigger an incoming call in the App, when a VoIP notification is received.
Below is my code in the ViewController.swift file
func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) {
// Process the received push
self.reportIncomingCall(uuid: UUID(), roomName: "testRoom", completion: nil)
}
func reportIncomingCall(uuid: UUID, roomName: String?, completion: ((NSError?) -> Void)? = nil) {
let callHandle = CXHandle(type: .generic, value: roomName ?? "")
let callUpdate = CXCallUpdate()
callUpdate.remoteHandle = callHandle
callUpdate.supportsDTMF = false
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
callUpdate.supportsUngrouping = false
callUpdate.hasVideo = true
callKitProvider.reportNewIncomingCall(with: uuid, update: callUpdate) { error in
if error == nil {
NSLog("Incoming call successfully reported.")
} else {
NSLog("Failed to report incoming call successfully: \(error?.localizedDescription).")
}
completion?(error as? NSError)
}
}
Twilio developer evangelist here.
I'm not particularly good with iOS, but taking a quick look at the documentation for the
PKPushRegistryDelegate
it looks like yourpushRegistry
function definition isn't right.It should be
That is,
didReceiveIncomingPushWith
rather thandidReceiveIncomingPushWithPayload
.Alternatively, does it have anything to do with the fact that you're casting
forType
toString
?