flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
133 stars 147 forks source link

CallKeepPerformAnswerCallAction Called Twice #108

Open rlee1990 opened 3 years ago

rlee1990 commented 3 years ago

I have noticed that CallKeepPerformAnswerCallAction is being called twice if another call is made without either closing the application or restarting the application. This so far has been tested on android and it causes the app to push the same route twice.

ejimenez93 commented 3 years ago

+1 we're getting this issue as well

rlee1990 commented 3 years ago

What I did as a workaround @ejimenez93 was this

_callkeep.on(CallKeepPerformAnswerCallAction(),
                (CallKeepPerformAnswerCallAction event) {
                  if (!showCall) {
                    print("called from tab");
                    if (Platform.isAndroid) {
                _callkeep.endAllCalls();
              }
                  final channel =
                  SNAB.streamChatClient.channel('message', id: callerId);
              AutoRouter.of(context).push(ChatVideoCallRoute(
                  channel: channel, uid: callerId, isIncoming: true));

              setState(() {
                showCall = true;
              });
                  }
                  Future.delayed(Duration(seconds: 1)).then((value) {
                    setState(() {
                      showCall = false;
                    });
                  });
            });