Starting an Incoming VoIP Call Using CallKit and Twilio-Video API

Using one example video application provided by Twilio ( VideoCallKitQuickStart ), I am trying to make an incoming call by sending a VoIP notification to the application. But the application does not call an incoming call. I also tried to keep the application open when sending VoIP notifications, and the application crashes by throwing the exception below

NSInvalidArgumentException: attempt to insert non-property list object "PKPushPayload: 0x16e44af0" for key Payload

Can someone please help me or point me in the right direction how to initiate an incoming call in an application when a VoIP notification is received.

Below is my code in 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) } } 
+2
ios twilio callkit twilio-api
source share
2 answers

Twilio evangelist developer is here.

I'm not very good at iOS, but by looking quickly at the documentation for PKPushRegistryDelegate , it seems that the definition of the pushRegistry function pushRegistry wrong.

It should be

 func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) 

That is, didReceiveIncomingPushWith , not didReceiveIncomingPushWithPayload .

Also, does it have anything to do with the fact that you're dropping forType into a String ?

0
source share

Swift 3.0

 func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) { NSLog("pushRegistry:didReceiveIncomingPushWithPayload:forType:") if (type == PKPushType.voIP) { print(payload.dictionaryPayload) VoiceClient.sharedInstance().handleNotification(payload.dictionaryPayload, delegate: self) } } 

And please do not make any changes to the payload without changing it so that the SDK retrieves incoming call information from the payload so that the SDK can notify the application of incoming calls

0
source share

All Articles