QuickBlox / quickblox-ios-sdk

QuickBlox iOS SDK for messaging and video calling
https://quickblox.com/developers/IOS
MIT License
397 stars 359 forks source link

Issue with calling when login on multiple devices #1342

Closed Maks273 closed 1 year ago

Maks273 commented 1 year ago

I have read the Documentation I have searched for a similar issue in the project and found none

I faced with an issue with iOS sdk and didn't found any solutions, unfortunately

Steps to reproduce:

  1. have any 3 devices
  2. login with userA in 2 devices and login with userB in last one device
  3. call from userB to userA
  4. answer call on the first device of userA

BUT it's still ringing on another(2nd device) of userA

QUESTION: how to solve the issue. I didn't found any delegate's methods to handle this case. Also tried to google the same question and check issues of this repo but guys also didn't get any answer of that

djmckee commented 1 year ago

+1, I see this issue too and I'm unsure how to capture this case within the QuickBlox SDK?

Is there an in-SDK solution or will I have to develop something bespoke like a WebSocket notification between devices?

VladimirNybozhinsky commented 1 year ago

@Maks273 @djmckee Hi there! For supporting multiple devices to receive signals like accept and reject by user on both phone you need to set QBSettings.carbonsEnabled = true . After that You can use the QBRTCClientDelegate method: session( , acceptedByUser userID, userInfo) and session( , rejectedByUser userID, userInfo) to detect that signals come from another user device and stop the call. To do this, call the CallKit’s CXProvider method: reportCall(with UUID: UUID, endedAt dateEnded: Date?, reason endedReason: CXCallEndedReason) with endedReason: answerElsewhere = 4 // The call was answered from another device

//MARK: - QBRTCClientDelegate

func session(_ session: QBRTCSession, acceptedByUser userID: NSNumber, userInfo: [String : String]? = nil) {
        if QBSession.current.currentUserID == userID.uintValue {
            provider.reportCall(with: call.uuid, endedAt: Date(), reason: .answeredElsewhere)
        }
    }
func session(_ session: QBRTCSession, rejectedByUser userID: NSNumber, userInfo: [String : String]? = nil) {
        if QBSession.current.currentUserID == userID.uintValue {
            provider.reportCall(with: call.uuid, endedAt: Date(), reason: .answeredElsewhere)
        }
    }

If you are using our “sample-videochat-webrtc-swift” then you can add next to SessionsController:

//MARK: - QBRTCClientDelegate
extension SessionsController: QBRTCClientDelegate {
    func session(_ session: QBRTCSession, acceptedByUser userID: NSNumber, userInfo: [String : String]? = nil) {
        if QBSession.current.currentUserID == userID.uintValue {
            removeSession(session.id)
        }
    }

    func session(_ session: QBRTCSession, rejectedByUser userID: NSNumber, userInfo: [String : String]? = nil) {
        if QBSession.current.currentUserID == userID.uintValue {
            removeSession(session.id)
            return
        }
    }
}
Maks273 commented 1 year ago

@VladimirNybozhinsky thanks, that makes sense