flutter-webrtc / callkeep

iOS CallKit and Android ConnectionService for Flutter
MIT License
130 stars 139 forks source link

CallKeepPerformAnswerCallAction handler not involked on Android #112

Open KienDangTran opened 2 years ago

KienDangTran commented 2 years ago

I've successfully received incoming call using FCM push on android device & default call screen of the OS has been shown, but when I click answer call button, CallKeepPerformAnswerCallAction handle is not invoked, it stays in call screen. The reject button works well. CallKeepPerformEndCallAction handler is invoked

On iOS both button work well when received a foreground push.

This is my code

      await _callKeep.setup(mainAppNavKey.currentContext, callSetup);
      final hasPhoneAccount = await _callKeep.hasPhoneAccount();
      if (!hasPhoneAccount) {
        await _callKeep.hasDefaultPhoneAccount(
          mainAppNavKey.currentContext!,
          callSetup,
        );
      }

      _callKeep.on(CallKeepPerformAnswerCallAction(),
            (CallKeepPerformAnswerCallAction event) async {
          final callUUID = event.callUUID!;
          print('[answerCall] $callUUID, number: +8418612345678');
        });

      FirebaseMessaging.onMessage.listen((msg) async {
        log('onMessage: ${msg.data}', name: '$runtimeType');
        // Handle data message
        final callerId = msg.data['caller_id'];
        final callerName = msg.data['caller_name'];
        final uuid = msg.data['uuid'];
        final hasVideo = msg.data['has_video']?.toString() == 'true';
        await _callKeep.displayIncomingCall(
          uuid,
          callerId,
          handleType: 'number',
          localizedCallerName: callerName,
          hasVideo: false,
        );
      });

I'm using version 0.3.1

❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-x64, locale en-VN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] VS Code (version 1.60.0)
[✓] Connected device (3 available)

Please help!

KienDangTran commented 2 years ago

I found an article describe similar symtoms: https://dev.to/chinmaykb/how-to-make-a-calling-app-in-flutter-for-android-devices-3hpg

Faaatman commented 2 years ago

Any news? it isn't displaying calls on Android physical phones. any help is appreciated :)

KienDangTran commented 2 years ago

use the latest code from commit dd1c872287287afc6fb8a40405091224bef18270 works in my case