Skip to content
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

Merged
merged 10 commits into from
Oct 22, 2021

Conversation

yingtao-butterflymx
Copy link
Contributor

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

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()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@sbelmeha sbelmeha Oct 20, 2021

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:

  1. Correct call ending from CallKit UI:
    CallsService.shared.endCurrentCallKitCall() should not be called in handleCallEnded because it's already ended by the users action.

  2. Correct call ending from custom UI:
    I think in case it's CallKit call the CallsService.shared.endCurrentCallKitCall should be called instead of direct calling of BMXCallKit.shared.endCall() in the hangUpAction from custom UI, so it will trigger provider(_ provider: CXProvider, perform action: CXEndCallAction) which will call BMXCallKit.shared.endCall().

Copy link
Contributor Author

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.

Copy link
Contributor

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:
Screenshot 2021-10-19 at 18 17 08

if we have these callbacks we would call CallsService.shared.endCurrentCallKitCall() only in callCanceled but not in callEnded

Copy link
Contributor Author

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() {
Copy link
Contributor

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

Copy link
Contributor Author

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
@yingtao-butterflymx yingtao-butterflymx merged commit d516940 into develop Oct 22, 2021
yingtao-butterflymx added a commit that referenced this pull request Nov 17, 2021
* 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
yingtao-butterflymx added a commit that referenced this pull request Nov 17, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants