gpt4 book ai didi

swift - 如何在真实应用中实现 CallKit?

转载 作者:行者123 更新时间:2023-11-28 15:04:07 27 4
gpt4 key购买 nike

我正在尝试在我的 VoIP 应用程序中实现 Apple CallKit。我正在使用 Xcode 9.2、Swift 4.0.3、iOS 10.3。问题是我不知道该怎么做。我试图在网络上搜索教程,但我没有找到基于真实系统的教程。他们都是用假系统,只是模拟通话!我有一个类,它与负责调用的第三方库一起管理。所以,如果我有来电发生,一些事件会通过观察者。像这样:

NotificationCenter.default.addObserver(forName: Notification.Name(rawValue: Notifications.Name.transMessage.rawValue), object: nil, queue: nil) { notification in
self.handleLibtransEvents()
}

其中 self.handleLibtransEvents 是私有(private)函数调用调用。另外,我在 AppDelegate.swift 中安装了 PUSH Notification 系统。像这样:

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("NOTIFICATION ERROR: \(error)")
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let pushToken = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}).lowercased()
print("pushToken: \(pushToken)")

}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if UIApplication.shared.applicationState != UIApplicationState.active {
// PUSH: Incoming call event!
}
}

所以有两个地方,我可以接听来电,但我不知道如何通过 Apple CallKit 接听真正的电话。我将感谢任何帮助、建议、调用示例。谢谢!P. S. 我已经正确安装了所有设置。

最佳答案

CallKit基本上是一个框架,当你接到一个 voip 电话或打一个新电话时,它会显示一个调用 UI,所以如果你给它传递一个数字 n 假设它会打电话,它什么都不做,记住它只是显示一个用于接听电话和调用电话的 UI。要调用电话和接听电话,您需要第三方服务,例如 Sinch和许多其他。

关于swift - 如何在真实应用中实现 CallKit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48681051/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com