flutter-webrtc / callkeep

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

[CallKeep][requestTransaction] Error requesting transaction #94

Open ScottLee97 opened 2 years ago

ScottLee97 commented 2 years ago
flutter: [answerCall] d09de8b9-77da-4e47-a158-95e29212b07a, number: +0123456789
flutter: backgroundMessage: CallKeepPerformAnswerCallAction d09de8b9-77da-4e47-a158-95e29212b07a
flutter: [setCurrentCallActive] d09de8b9-77da-4e47-a158-95e29212b07a, callerId: +0123456789, callerName: Draco
[CallKeep][startCall] uuidString = d09de8b9-77da-4e47-a158-95e29212b07a
[CallKeep][requestTransaction] transaction = <CXTransaction 0x283692240 UUID=84550605-94CF-4DE5-925F-3F6C5C386A6F isComplete=0 actions=(
    "<CXStartCallAction 0x280435290 UUID=452D7630-692A-4D14-8E37-C7D65B31BE4F state=0 commitDate=(null) callUUID=D09DE8B9-77DA-4E47-A158-95E29212B07A handle=<CXHandle 0x283691300 type=PhoneNumber value=+0123456789> contactIdentifier=Draco video=0 relay=0 upgrade=0 retry=0 emergency=0 isVoicemail=0 ttyType=0 localLandscapeAspectRatio={0, 0} localPortraitAspectRatio={0, 0} dateStarted=(null) localSenderIdentityUUID=(null) shouldSuppressInCallUI=0>"
)>
[CallKeep][requestTransaction] Error requesting transaction ((
    "<CXStartCallAction 0x280435290 UUID=452D7630-692A-4D14-8E37-C7D65B31BE4F state=0 commitDate=(null) callUUID=D09DE8B9-77DA-4E47-A158-95E29212B07A handle=<CXHandle 0x283691300 type=PhoneNumber value=+0123456789> contactIdentifier=Draco video=0 relay=0 upgrade=0 retry=0 emergency=0 isVoicemail=0 ttyType=0 localLandscapeAspectRatio={0, 0} localPortraitAspectRatio={0, 0} dateStarted=(null) localSenderIdentityUUID=(null) shouldSuppressInCallUI=0>"
)): (Error Domain=com.apple.CallKit.error.requesttransaction Code=6 "(null)")

Here's the error message I am receiving when I answer the call when the app is in the background. It seems like callkeep is calling a startcall function when I pick up the call when the app is in the background and calls the startcall function again when the app returns to the foreground.

I was using the code from the example code for callkeep.

I suspect that it is because we called start call at the background handler as shown:

final callUUID = uuid ?? Uuid().v4();
  _callKeep.on(CallKeepPerformAnswerCallAction(),
      (CallKeepPerformAnswerCallAction event) {
    print(
        'backgroundMessage: CallKeepPerformAnswerCallAction ${event.callUUID}');
    _callKeep.startCall(event.callUUID, callerId, callerNmae);

    Timer(const Duration(seconds: 1), () {
      print(
          '[setCurrentCallActive] $callUUID, callerId: $callerId, callerName: $callerNmae');
      _callKeep.setCurrentCallActive(callUUID);
    });
  });

and we called the function again in the init state

@override
  void initState() {
    super.initState();
    _callKeep.on(CallKeepDidDisplayIncomingCall(), didDisplayIncomingCall);
    _callKeep.on(CallKeepPerformAnswerCallAction(), answerCall);
    _callKeep.on(CallKeepDidPerformDTMFAction(), didPerformDTMFAction);
    _callKeep.on(
        CallKeepDidReceiveStartCallAction(), didReceiveStartCallAction);
    _callKeep.on(CallKeepDidToggleHoldAction(), didToggleHoldCallAction);
    _callKeep.on(
        CallKeepDidPerformSetMutedCallAction(), didPerformSetMutedCallAction);
    _callKeep.on(CallKeepPerformEndCallAction(), endCall);
    _callKeep.on(CallKeepPushKitToken(), onPushKitToken);

Can anyone share with me how they resolve this issue?