4

Twilio が提供するサンプルのビデオ通話アプリ ( VideoCallKitQuickStart ) の 1 つを使用して、VoIP 通知をアプリに送信して着信通話をトリガーしようとしています。しかし、アプリは着信をトリガーしません。また、VoIP 通知を送信している間、アプリを開いたままにしておくことを試みましたが、以下の例外をスローして、アプリがクラッシュしました。

NSInvalidArgumentException: 非プロパティ リスト オブジェクト 'PKPushPayload: 0x16e44af0' をキー ペイロードに挿入しようとしています

VoIP 通知を受信したときに、アプリで着信コールをトリガーする方法を教えてください。

以下はViewController.swiftファイルの私のコードです

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

3 に答える 3

0

Twilio 開発者エバンジェリストはこちら。

私はiOSが特に得意ではありませんが、ドキュメントをざっと見てみると、 関数定義が正しくないPKPushRegistryDelegateようです。pushRegistry

そのはず

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

つまり、didReceiveIncomingPushWithではなくdidReceiveIncomingPushWithPayload.

または、キャストforTypeしているという事実と関係がありますStringか?

于 2017-01-06T10:57:44.610 に答える