【发布时间】:2021-06-02 03:00:34
【问题描述】:
我们正在为 Flutter 创建一个 TwilioProgrammableVoice 插件:https://github.com/izio38/twilio_programmable_voice/tree/ios-platform。
按下按钮时示例应用程序应该做什么:
- 调用插件方法
makeCall - 插件方法应该调用名为
makeCall的平台特定方法 - 然后它应该在 CXController 上创建一个
CXStartCallAction - 完成后,它应该更新对
CXProivder的调用 - 应该调用
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