每当我在 VOIP 应用程序中接到来电时,我都可以在 native iPhone 通话 UI 上看到日志。
我想通过单击最后一个来电从 UI 的 native iPhone 通话记录中调用电话。就像它适用于 WhatsApp、Skype、环聊等。
如何才能拨出电话?
以下是我为来电编写的方法:
-(void)reportIncomingCall:(NSUUID*)UDID handle:(NSString*)handle;
-(CXCallController*)startCall:(NSUUID*)UDID handle:(NSString*)handle
-(void)connectCallWithCallController:(CXCallController*)controller
我知道还有一种拨出电话的方法。但我不知道什么时候调用这个:
- (NSUUID *)reportOutgoingCallContactIdentifier:(NSString *)identifier destination:(NSString *)name telNumber:(NSString *)telnum
最佳答案
当点击 native iOS 通话记录中的项目时,将调用应用程序委托(delegate)的 continueUserActivity 函数。我的实现在 Swift 中看起来像这样:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
self.startCallHandle = userActivity.startCallHandle
// Cache call handle here, and make call using cached call handle
// when applicationDidBecomeActive is called
return true
}
startCallHandle 在文件 NSUserActivity+StartCallConvertible.swift 中定义,如 SpeakerBox 示例项目所示。
在您应用的 Info.plist 中,您必须具有 INStartAudioCallIntent 和/或 INStartVideoCallIntent。再次查看 SpeakerBox 示例应用以获取详细信息。
关于ios - 来自 native 调用 UI 的 VOIP 去电,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53989833/