【问题标题】:iOS - Trigger outgoing VOIP Call on clicking the caller in the native iOS Recent call table viewiOS - 在本机 iOS 最近通话表视图中单击呼叫者时触发传出 VOIP 呼叫
【发布时间】:2018-01-19 10:14:47
【问题描述】:

我已经为我的应用实现了 CallKit,以使用 WebRTC 在我们的应用中触发/接收音频和视频通话。可以无缝运行,没有任何问题。

据我所知,有 3 种方法可以从 Call Kit 触发呼叫。

  1. 在应用程序中执行交互
  2. 使用受支持的自定义 URL 方案打开链接
  3. 使用 Siri 发起 VoIP 呼叫

到目前为止,我没有任何要求使用 Siri 发起呼叫,但我们需要在用户单击本机 iOS 最近呼叫屏幕中的任何单元格时发起呼叫,然后路由到我们的应用程序并触发外出通话。

而且当用户呼叫其他用户时,我们的应用程序包含很少的元数据,例如receiverID 等。所以当用户错过其他用户的呼叫时,我需要存储这些元数据,并且需要在用户调用时触发呼叫使用所有这些元数据点击 iOS 最近通话屏幕的未接来电列表。

我正在浏览 Apple 提供的 CallKit“Speakerbox”示例应用程序。我发现他们正在使用自定义 URL 方案,就像我们用于 iOS 应用程序的 DeepLinking 一样。

所以我需要很少的建议是否可以使用 URL 方案来实现,如果可以,我如何将元数据(自定义对象)存储在 CXHandle 对象中。

【问题讨论】:

    标签: ios swift voip url-scheme callkit


    【解决方案1】:

    从我这里粘贴相同的答案:Refer

    验证 remoteHandle 和supportedHandleTypes,两者都应该根据您的要求相似。

    callUpdate.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:[NSString stringWithFormat:@"%@", phoneno]];
    configuration.supportedHandleTypes = [NSSet setWithObjects:[NSNumber numberWithInteger:CXHandleTypeGeneric],[NSNumber numberWithInteger:CXHandleTypePhoneNumber], nil];
    

    如果句柄不匹配,则无法处理 NSUserActivity。

    实现此方法获取回调,

    - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray * _Nullable))restorationHandler {}

    【讨论】:

    • 只有当 remoteHandle 是电话号码时才有效?如果远程句柄是带有人名的字符串怎么办?
    • @RohitSharma 我有同样的问题,在我的情况下,我的应用程序可以使用名称(注册用户)或电话号码(非注册用户)作为 CallerId 来电。那么,当他们通过点击最近通话中的姓名开始通话时,我如何才能获得电话号码?
    【解决方案2】:

    对于 Swift 5,您应该将 continueuserActivity 函数定义为 SceneDelegate.swift,如下所示

       func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
     
            let interaction = userActivity.interaction
            if let startAudioCallIntent = interaction?.intent as? INStartAudioCallIntent{
        
                let contact = startAudioCallIntent.contacts?.first
            
                let contactHandle = contact?.personHandle
    
                    if let phoneNumber = contactHandle?.value {
                       print(phoneNumber)
                       // Your call logic
                    }
         
            }
            return
        }
    

    请参考answer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 2012-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多