-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: refactor code to handle more call scenarios #25
Conversation
make IncomingCallViewController conform to BMXCall.IncomingCallUIInputs call new API BMXCallKit.shared.processCall(guid:callType:incomingCallPresenter:completion) to process incoming calls.
use DispatchQueue.main.async in our SDK instead to make users easier to use the SDK.
pass unwrapped incomingViewController (with guard let) to processCall
only reportNewIncomingCall for the intial call. show IncomingCallViewContrller after users press the accept button
@@ -233,5 +208,4 @@ extension IncomingCallViewController: BMXCall.IncomingCallUIInputs { | |||
CallsService.shared.endCurrentCallKitCall() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will "handleCallEnded" be called in case I decline a call from CallKit UI? If yes, then we don't need to call CallsService.shared.endCurrentCallKitCall
because it in order will call CallKit delegate function func provider(_ provider: CXProvider, perform action: CXEndCallAction)
which will call the end call function of the BMXCall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should delete this handleCallEnded in IncomingCallViewController because I moved it to IncomingCallPresenter.
Also based on my tests, when I decline a call from CallKit UI, it will directly call provider(_ provider: CXProvider, perform action: CXEndCallAction)
which will call BMXCallKit.shared.endCall()
, then handleCallEnded in IncomingCallPresenter will be called after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so when handleCallEnded
is called then you will call CallsService.shared.endCurrentCallKitCall()
and it will trigger provider(_ provider: CXProvider, perform action: CXEndCallAction)
again which will call BMXCallKit.shared.endCall()
, but the call is already ended. This is not good.
There are 2 situations which should be handled correctly in case it's CallKit call:
-
Correct call ending from CallKit UI:
CallsService.shared.endCurrentCallKitCall()
should not be called inhandleCallEnded
because it's already ended by the users action. -
Correct call ending from custom UI:
I think in case it's CallKit call theCallsService.shared.endCurrentCallKitCall
should be called instead of direct calling ofBMXCallKit.shared.endCall()
in thehangUpAction
from custom UI, so it will triggerprovider(_ provider: CXProvider, perform action: CXEndCallAction)
which will callBMXCallKit.shared.endCall()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also use handleCallEnded when panel side cancels a call before users answer it. In that scenario, CallsService.shared.endCurrentCallKitCall() seems needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yingtao-butterflymx in the case it's ended on panel side - yes, you need to call CallsService.shared.endCurrentCallKitCall()
So maybe that is the reason to have a callback with more info to know better why it's ended.
For example like it was before:
if we have these callbacks we would call CallsService.shared.endCurrentCallKitCall()
only in callCanceled
but not in callEnded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But calling CallsService.shared.endCurrentCallKitCall() still triggers provider(_ provider: CXProvider, perform action: CXEndCallAction)
which calls BMXCallkit.shared.endCall()
call CallsService.shared.endCurrentCallKitCall() instead of BMXCallKit.shared.endCall() in hangUpAction remove function handleCallEnded
class CallStatusHandler: BMXCall.CallStatusDelegate { | ||
weak var incomingCallViewController: IncomingCallViewController? | ||
|
||
func handleCallConnected() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to rename handleCallConnected to callConnected and handleCallAccepted to callAccepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it.
remove CallEndReason
use callConnected instead of handleCallConnected use callAccepted instead of handleCallAccepted
* feat: incorporate Monarch support in the iOS Demo app (#24) * feat: use WebRTC supported SDK to open door make IncomingCallViewController conform to BMXCall.IncomingCallUIInputs call new API BMXCallKit.shared.processCall(guid:callType:incomingCallPresenter:completion) to process incoming calls. * refactor: remove some DispatchQueue.main.async use DispatchQueue.main.async in our SDK instead to make users easier to use the SDK. * refactor: remove extension for BMXCallDelegate * refactor: pass unwrapped incomingViewController pass unwrapped incomingViewController (with guard let) to processCall Refs # NT-458 * refactor: refactor code to handle more call scenarios (#25) * feat: use WebRTC supported SDK to open door make IncomingCallViewController conform to BMXCall.IncomingCallUIInputs call new API BMXCallKit.shared.processCall(guid:callType:incomingCallPresenter:completion) to process incoming calls. * refactor: remove some DispatchQueue.main.async use DispatchQueue.main.async in our SDK instead to make users easier to use the SDK. * refactor: remove extension for BMXCallDelegate * refactor: pass unwrapped incomingViewController pass unwrapped incomingViewController (with guard let) to processCall * refactor: add IncomingCallPresenter only reportNewIncomingCall for the intial call. show IncomingCallViewContrller after users press the accept button * fix: review fixes call CallsService.shared.endCurrentCallKitCall() instead of BMXCallKit.shared.endCall() in hangUpAction remove function handleCallEnded * refactor: use CallStatusHandler to handel handle call status changes * fix: review fixes remove CallEndReason * fix: review fixes use callConnected instead of handleCallConnected use callAccepted instead of handleCallAccepted Refs # NT-458 * fix: simplify Podfile * feat: mark Intercom and Keypads for devices (#26) add subtitle for DoorTableViewCell to show the current device is Intercom or KeyPad add setup(by device: DeviceModel) in DoorTableViewCell * chore: import BMXCore 2.1.0 and BMXCall 2.1.0
* feat: incorporate Monarch support in the iOS Demo app (#24) * feat: use WebRTC supported SDK to open door make IncomingCallViewController conform to BMXCall.IncomingCallUIInputs call new API BMXCallKit.shared.processCall(guid:callType:incomingCallPresenter:completion) to process incoming calls. * refactor: remove some DispatchQueue.main.async use DispatchQueue.main.async in our SDK instead to make users easier to use the SDK. * refactor: remove extension for BMXCallDelegate * refactor: pass unwrapped incomingViewController pass unwrapped incomingViewController (with guard let) to processCall Refs # NT-458 * refactor: refactor code to handle more call scenarios (#25) * feat: use WebRTC supported SDK to open door make IncomingCallViewController conform to BMXCall.IncomingCallUIInputs call new API BMXCallKit.shared.processCall(guid:callType:incomingCallPresenter:completion) to process incoming calls. * refactor: remove some DispatchQueue.main.async use DispatchQueue.main.async in our SDK instead to make users easier to use the SDK. * refactor: remove extension for BMXCallDelegate * refactor: pass unwrapped incomingViewController pass unwrapped incomingViewController (with guard let) to processCall * refactor: add IncomingCallPresenter only reportNewIncomingCall for the intial call. show IncomingCallViewContrller after users press the accept button * fix: review fixes call CallsService.shared.endCurrentCallKitCall() instead of BMXCallKit.shared.endCall() in hangUpAction remove function handleCallEnded * refactor: use CallStatusHandler to handel handle call status changes * fix: review fixes remove CallEndReason * fix: review fixes use callConnected instead of handleCallConnected use callAccepted instead of handleCallAccepted Refs # NT-458 * fix: simplify Podfile * feat: mark Intercom and Keypads for devices (#26) add subtitle for DoorTableViewCell to show the current device is Intercom or KeyPad add setup(by device: DeviceModel) in DoorTableViewCell * chore: import BMXCore 2.1.0 and BMXCall 2.1.0 * chore: import BMXCall 2.1.1
add IncomingCallPresenter which conform to IncomingCallUIInputs
pass IncomingCallPresenter to SDK instead of IncomingCallViewController
only reportNewIncomingCall for the initial call.
show IncomingCallViewContrller after users press the accept button