hiennguyen92 / flutter_callkit_incoming

Flutter Callkit Incoming
https://pub.dev/packages/flutter_callkit_incoming
MIT License
182 stars 314 forks source link

Wrong event: (ACTION_CALL_ENDED) emitted if declining/rejecting a call during an already active call #249

Open AbdurrehmanSubhani opened 1 year ago

AbdurrehmanSubhani commented 1 year ago

Hey, if the title seems a bit confusing let me explain the complete scenario here. So im building a VoIP application and was testing out a few use cases and found out that my logic was not working in a specific scenario. The scenario goes as follows:

  1. There are 3 users involved in this scenario: lets call them User A, User B and User C.
  2. User A calls User B
  3. I use this package to show that User B has received a call (through showCallkitIncoming) on which User B accepts the call (through startCall(udid) ).
  4. Call 1 is going fine, a few min/sec later, User C call User A. I display this call using the same package function (through showCallkitIncoming) and User A rejects this incoming call through the callkit interface, here is where the problem arises.

The expected behaviour from the package was as follows: On receiving an incoming call whilst Call 1 is active, declining the incoming call should have emitted the event: ACTION_CALL_DECLINE

Package behaviour in this scenario: The package does not emit the event ACTION_CALL_DECLINE and instead only emits the event: ACTION_CALL_ENDED, this is breaking my Call Decline/Reject and Call Ended logic.

The events work fine in case their isn't an on going/ active call, on decline ACTION_CALL_DECLINE is emitted followed by ACTION_CALL_ENDED (im not sure why this event is fired though).

Any help around this would be much appreciated. Thanks!

ribalassaf commented 11 months ago

Hello, Did you find anything about this?

AbdurrehmanSubhani commented 11 months ago

Hello, Did you find anything about this?

No fixes for this package itself, but adjusted my processing logic to cater this scenario and shifted to: https://pub.dev/packages/connectycube_flutter_call_kit

Quite a while ago but here's what i remember i did:

Added 3 additional attributes to maintain call Ids in my call manager:

  1. Incoming call id -> set when receiving and displaying a new call, reset if declined or accepted.
  2. On going call id -> set when the call is accepted and a session is established, reset when a session ends.
  3. Out going call id -> set when the call session is initiated from the caller side, reset if the call accepted/declined.

When ever a call end function was called inside the manager, i'd compare the call Id for which the end call function was called to the attributes above:

for another specific case:

Hope this helps.