简体   繁体   English

Twilio iOS视频通话:当用户拒绝通话时出现“用户不可用”错误消息

[英]Twilio iOS Video Call: Getting “User is unavailable” error message when user rejects the call

I am implementing twilio's video call in my iOS application. 我正在iOS应用程序中实现twilio的视频通话。 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推送通知。

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. 我试图实现的解决方案是,当呼叫返回“用户不可用”错误时,我会告诉我的后端向对方发送VoIP通知,这个解决方案的问题是我发现了twilio的错误,有时如果用户拒绝调用twilio的SDK返回错误的错误消息,说“用户不可用”而不是“用户拒绝呼叫”消息的错误。 So I can't know if the user was really unavailable (to send the VoiP notification) or if the user just rejected the call 所以我不知道用户是否真的不可用(发送VoiP通知)或者用户是否刚刚拒绝了呼叫

How to reproduce the error? 如何重现错误? 1. Connect two clients with fixed identity id. 1.连接具有固定身份ID的两个客户端。 For example "identity1" and "identity2" 2. Make a call from "identity1" to "identity2" and rejects it from "identity2". 例如“identity1”和“identity2”2。从“identity1”拨打“identity2”并从“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. 您将收到正确的错误消息“用户拒绝呼叫”3.关闭“identity2”中的应用程序而不要呼叫解除,只需终止应用程序。 4. Then start the app again in "identity2" (change the token if you want but let the same identity id). 4.然后在“identity2”中再次启动应用程序(如果需要,请更改令牌,但使用相同的身份ID)。 5. Make a call from "identity1" to "identity2" and rejects it from "identity2". 5.从“identity1”拨打“identity2”并从“identity2”拒绝。 You will receive the wrong error message "User is unavailable" instead "User rejects the call". 您将收到错误的错误消息“用户不可用”而不是“用户拒绝呼叫”。

Thats the problem is like twilio would not remove the old client's instance if we don't call unlisten. 多数民众赞成问题就像twilio不会删除旧客户端的实例,如果我们不调用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. 如果我在用户不可用或仅拒绝呼叫时无法区分,那么我无法在真正需要时发送VoIP推送。

In order to receive incoming call, you have to call listen API on each launch of the app. 要接收来电,您必须在每次启动应用时调用listen API。 It seems you might be killing the app after listen but after relaunch listen was not called on client. 看起来你可能会在listen之后杀死应用程序但是在重新启动之后没有在客户端上调用listen So when the remote party makes an outbound call, it is getting TWCErrorCodeConversationParticipantNotAvailable . 因此,当远程方进行出站呼叫时,它将获得TWCErrorCodeConversationParticipantNotAvailable

Once conversation client starts listening for incoming calls, remote party should receive TWCErrorCodeConversationRejected on reject. 会话客户端开始侦听传入呼叫后,远程方应在拒绝时收到TWCErrorCodeConversationRejected

In other words, if A calls B, and B is not listening (ie not called listen on client), A will receive “user is unavailable". 换句话说,如果A呼叫B,并且B没有监听(即不在客户端上称为listen ),则A将接收“用户不可用”。

The example in Swift: 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! 如果这有帮助,请告诉我!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM