QiscusRTC
Qiscus RTC SDK 是一个易于将语音通话添加到移动应用的产品。它处理所有信号和音频管理的复杂性,同时为您创建令人惊叹的用户界面提供自由。我们强烈建议您实现更好的推送通知以增加通话可靠性,例如 APNs、Pushkit、MQTT 或其他标准消息协议。
Callkit 支持
快速入门
以下是首次设置 Qiscus RTC SDK 的分步指南
依赖项
将以下内容添加到您的项目 podfile 中
platform :ios, '10.0'
pod 'QiscusRTC'
import QiscusRTC
权限
将相机和麦克风添加到您的项目 info.plist 中
调用套件
在.plist文件中增加该配置
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
<string>audio</string>
<string>voip</string>
</array>
身份验证
初始化 Qiscus
在您的应用程序中初始化 Qiscus
参数
- app_id: 字符串
- app_secret: 字符串
QiscusRTC.setup(appId: [Your_AppID], appSecret: [Your_Secret_Key])
要获取您的 app_id
和 app_secret
,请 联系我们。
使用自定义主机初始化
Qiscus 还提供本地部署包,因此您可以自己托管信令服务器。请 联系我们 以获取更多信息。
参数
- app_id: 字符串
- app_secret: 字符串
- host: 字符串
QiscusRTC.setup(appId: [Your_AppID], appSecret: [Your_Secret_Key], host: [Your_server])
方法
注册用户
在用户开始互相通话之前,他们必须将用户注册到我们的服务器
参数
- username: 字符串
- displayName: 字符串
QiscusRTC.register(username: "[email protected]", displayName: "juang")
开始通话
开始通话,作为被叫方,您可以使用用户名呼叫任何人。您可以定义房间ID,也可以将其留空,我们将生成随机的房间ID。
启动通话对象
- roomId: 字符串
- calleeUsername: 字符串
- calleeDisplayName: 字符串
- isVideo: 布尔值
- calleeDisplayAvatar: URL
QiscusRTC.startCall(roomId: "unique_room_id", isVideo: true/true, calleeUsername: "[email protected]", calleeDisplayName: "Evan P", calleeDisplayAvatar: URL(string: "http://...") { (target, error) in
if error == nil {
self.present(target, animated: true, completion: nil)
}
}
来电
当您收到信号、消息或事件来电时。您必须设置roomID和通话者用户名以验证通话。
启动通话对象
- roomId: 字符串
- calleerUsername: 字符串
- calleerDisplayName: 字符串
- isVideo: 布尔值
- calleerDisplayAvatar: URL
QiscusRTC.incomingCall(roomId: "receive_room_id", isVideo: false/true, calleerUsername: "[email protected]", calleerDisplayName: "juang", calleerDisplayAvatar: URL(string: "http://...") { (target, error) in
if error == nil {
self.present(target, animated: true, completion: nil)
}
}
继续通话
当您在后台或锁屏状态下接收通话时,打开所需应用,需要进行视图跳转到通话界面。
if QiscusRTC.isCallActive {
let target = currentViewController()
let callUI = QiscusRTC.getCallUI()
target.navigationController?.present(callUI, animated: true, completion: {
// Your Code
})
}