Twilio iOS视频通话:获取“用户不可用"用户拒绝呼叫时出现错误消息 [英] Twilio iOS Video Call: Getting "User is unavailable" error message when user rejects the call

查看:49
本文介绍了Twilio iOS视频通话:获取“用户不可用"用户拒绝呼叫时出现错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iOS应用程序中实现twilio的视频通话.问题是我正在寻找一种方法来知道对方应用程序何时死亡,以便向他发送VoIP推送通知.

I am implementing twilio's video call in my iOS application. The problem is that I am looking for a way to know when the counterpart application is dead to send him a VoIP Push notification.

我尝试实现的解决方案是,当呼叫返回用户不可用"错误时,我会告诉后端将VoIP通知发送给对方,此解决方案的问题是我发现了twilio的错误,其中有时,如果用户拒绝呼叫,则twilio的SDK会返回错误消息用户不可用",而不是用户拒绝呼叫"消息.所以我不知道该用户是否真的不可用(发送VoiP通知),或者该用户只是拒绝了呼叫

The solution I was trying to implement was that, when the call returns "User is unavailable" error then i would tell my backend to send VoIP notification to the counterpart, the problem with this solution is that I found a twilio's bug where sometimes if the user rejects the call twilio's SDK returns a wrong error message saying "User is unavailable" instead an error with "User rejects the call" message. So I can't know if the user was really unavailable (to send the VoiP notification) or if the user just rejected the call

如何重现该错误?1.连接具有固定标识ID的两个客户端.例如"identity1"和"identity2"2.从"identity1"打到"identity2",并从"identity2"拒绝.您将收到正确的错误消息用户拒绝呼叫"3.在"identity2"中关闭该应用程序,而无需打电话取消收听,只需杀死该应用程序即可.4.然后在"identity2"中再次启动该应用程序(如果需要,请更改令牌,但要使用相同的身份ID).5.从"identity1"打到"identity2",并从"identity2"拒绝.您将收到错误的错误消息用户不可用",而不是用户拒绝呼叫".

How to reproduce the error? 1. Connect two clients with fixed identity id. For example "identity1" and "identity2" 2. Make a call from "identity1" to "identity2" and rejects it from "identity2". You will receive the correct error message "User rejects the call" 3. Close the app in "identity2" WITHOUT CALLING UNLISTEN, just kill the app. 4. Then start the app again in "identity2" (change the token if you want but let the same identity id). 5. Make a call from "identity1" to "identity2" and rejects it from "identity2". You will receive the wrong error message "User is unavailable" instead "User rejects the call".

那是问题所在,如果我们不致电取消监听,twilio不会删除旧客户端的实例.而且,如果我不能区分用户何时不可用或何时拒绝呼叫,那么我就不能在真正需要时发送VoIP推送.

Thats the problem is like twilio would not remove the old client's instance if we don't call unlisten. And if I can't difference when user is unavailable or when just rejects the call then I can't send the VoIP push when is really needed.

推荐答案

为接收来电,您必须在每次启动该应用程序时调用 listen API.看来您可能是在 listen 之后杀死了该应用程序,但是在客户端上未重新启动 listen 之后.因此,当远程方打出电话时,它会得到 TWCErrorCodeConversationParticipantNotAvailable .

In order to receive incoming call, you have to call listen API on each launch of the app. It seems you might be killing the app after listen but after relaunch listen was not called on client. So when the remote party makes an outbound call, it is getting TWCErrorCodeConversationParticipantNotAvailable.

一旦会话客户端开始侦听来电,对方将在拒绝时收到 TWCErrorCodeConversationRejected .

Once conversation client starts listening for incoming calls, remote party should receive TWCErrorCodeConversationRejected on reject.

换句话说,如果A呼叫B,而B没有监听(即在客户端上未呼叫 listen ),则A将收到用户不可用".

In other words, if A calls B, and B is not listening (i.e. not called listen on client), A will receive "user is unavailable".

Swift中的示例:

/* Create an AccessManager - this provides a single place to update your Twilio
Access Token when using multiple Twilio SDKs */
var accessManager = TwilioAccessManager(token:self.accessToken, delegate:self)

// Create a Conversations Client and listen for IncomingInvites
var client = TwilioConversationsClient(accessManager: accessManager, delegate: self)
client!.listen()


// MARK: TwilioConversationsClientDelegate

// Selectively handle IncomingInvites based on the originator
func conversationsClient(conversationsClient: TwilioConversationsClient, 
                         didReceiveInvite invite: TWCIncomingInvite) {
    if (invite.from == "ringo") {
        invite.reject()
    } else {
        /* See the "Specify Local Media Constraints when Creating a
        Conversation" guide for instructions on constructing LocalMedia */
        invite.acceptWithLocalMedia(self.localMedia!) { conversation, error in
            self.conversation = conversation
            self.conversation!.delegate = self
        }
    }
}

请告诉我这是否有帮助!

Please let me know if this helps at all!

这篇关于Twilio iOS视频通话:获取“用户不可用"用户拒绝呼叫时出现错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆