代码之家  ›  专栏  ›  技术社区  ›  i70ro

iOS-在本机iOS最近的呼叫表视图中单击呼叫者时触发传出VOIP呼叫

  •  1
  • i70ro  · 技术社区  · 7 年前

    我已经为我的应用程序实现了CallKit,通过使用WebRTC在我们的应用程序中触发/接收音频和视频呼叫。它可以无缝工作,没有任何问题。

    正如我所见,有3种方法可以触发呼叫套件中的呼叫。

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

    而且,当用户调用其他用户(如receiverID等)时,我们的应用程序包含的元数据也很少。。因此,当用户错过其他用户的呼叫时,我需要存储此元数据,并且当用户使用所有这些元数据单击iOS最近呼叫屏幕的错过呼叫列表时,我需要触发呼叫。

    我正在浏览苹果公司提供的CallKit“Speakerbox”的示例应用程序。我发现他们使用的是自定义URL方案,就像我们用于iOS应用程序深度链接的一样。

    因此,我需要一些建议,看看是否可以使用URL方案来实现这一点,如果可以的话,我如何在CXHandle对象中存储元数据(自定义对象)。

    2 回复  |  直到 7 年前
        1
  •  5
  •   Community Neeleshkumar S    4 年前

    在此处粘贴我的相同答案: Refer

    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 {}

        2
  •  0
  •   Bilal Şimşek    3 年前

    对于Swift 5,您应该为SceneDelegate定义continueuserActivity函数。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