【问题标题】:Flutter Plugin / iOS / CallKit Provider doesn't receive CXStartCallAction eventFlutter Plugin / iOS / CallKit Provider 没有收到 CXStartCallAction 事件
【发布时间】:2021-06-02 03:00:34
【问题描述】:

我们正在为 Flutter 创建一个 TwilioProgrammableVoice 插件:https://github.com/izio38/twilio_programmable_voice/tree/ios-platform

按下按钮时示例应用程序应该做什么:

  1. 调用插件方法makeCall
  2. 插件方法应该调用名为makeCall的平台特定方法
  3. 然后它应该在 CXController 上创建一个CXStartCallAction
  4. 完成后,它应该更新对CXProivder的调用
  5. 应该调用 perform 方法,因为我们使用 StartCallAction 委托给 self

由于某些我自己无法识别的原因,第 5 点没有完成。

这里是 iOS makeCall 内容(故意减少):

// In TwilioProgrammableVoice.swift
public class TwilioProgrammableVoice: NSObject {
    func makeCall(to: String) {
        print("makeCall to", to)
        if self.twilioVoiceDelegate!.call != nil && self.twilioVoiceDelegate!.call?.state == .connected {
            self.twilioVoiceDelegate!.userInitiatedDisconnect = true
            self.callKitDelegate.performEndCallAction(uuid: self.twilioVoiceDelegate!.call!.uuid!)
        } else {
            // Probably not the right place for such an assignment
            TwilioVoice.audioDevice = audioDevice;
            let uuid = UUID()
            print("UUID : ", uuid)
            self.callKitDelegate.performStartCallAction(uuid: uuid, handle: to)
        }
    }
}

// In CallKitDelegate.swift
class CallKitDelegate: NSObject, CXProviderDelegate {
    var callKitProvider: CXProvider
    let callKitCallController = CXCallController()

    override init () {
        let configuration = CXProviderConfiguration(localizedName: SwiftTwilioProgrammableVoicePlugin.appName)
        callKitProvider = CXProvider(configuration: configuration)

        super.init();

        // We do delegate so we are notified when events occurs on CXProvider
        callKitProvider.setDelegate(self, queue: nil)
    }
    
    // This isn't always triggered
    public func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
        print("provider called CXStartCallAction")
        provider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: Date())

        TwilioProgrammableVoice.sharedInstance.performVoiceCall(uuid: action.callUUID, client: "") { (success) in
            print("in performVoiceCall cb")
                if success {
                    print("success case")
                        provider.reportOutgoingCall(with: action.callUUID, connectedAt: Date())
                } else {
                    print("not success case")
                }
        }

        action.fulfill()
    }
}

奇怪的是它有时有效,有时无效。当它运行时,我们有大量来自 Twilio 和 CX 的日志。

当它不工作时,我们有来自 CX 的日志(我认为,我不能肯定地说),因为我们的应用程序不会使用表情符号记录任何内容。它确实说::thumbup: VoIP CXStartCallAction:microphone: didActivate audioSession

【问题讨论】:

    标签: ios swift flutter flutter-packages


    【解决方案1】:

    就我而言,我正在使用另一个插件来初始化CXProvider。它是在我之后初始化的。所以它就像“被替换”了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多