azure-sdk-for-ios icon indicating copy to clipboard operation
azure-sdk-for-ios copied to clipboard

[BUG] Not receiving didRecieveIncomingCall method on call agent delegate after successfully handlePush

Open MitchMooreVH opened this issue 4 months ago • 7 comments

Describe the bug I am trying to receive an incoming pstn call. I am sending the push notification to apns. I based the push notification of the request here.

I'm getting the voip push notification on my phone, I'm able to report incoming call. And I can successfully handle the push with callAgent.handlePush(notification: callNotification), the error is nil in the completion handler. The issue is that after handle push the call agent delegate didRecieveIncomingCall (also I think Receive is spelt wrong on that method) is not being called to set the incoming call to accept it.

Here are some notable logs that might help:

Exception or Stack Trace [ACSCallAgent][handlePushNotification:withCompletionHandler:]<0x280661540>: callId: 708FB761-AFEE-46EB-8D09-89116EA40291 => [HandlePush] Successfully processed incoming PN payload

[#8ac52767-S] T#48651 S.25 [DEBUG2] [calling.csa] 8ac52767: 708fb761-afee-46eb-8d09-89116ea40291 Initial WaitingForAttachReady [#3231f04e-S] T#48651 S.25 [DEBUG2] [calling.csa] 3231f04e: 708fb761-afee-46eb-8d09-89116ea40291 Connecting [#bf4dd107-S] T#48651 S.25 [DEBUG2] [calling.csa] bf4dd107: WaitingForAttachReady [#9ed978b9-S] T#48651 S.25 [DEBUG2] [calling.csa] 9ed978b9: Idle Connecting

[#6f5d6b41-S] T#48651 S.25 [DEBUG2] [calling.csa] 6f5d6b41: 708fb761-afee-46eb-8d09-89116ea40291 Connecting [#debd7458-S] T#48651 S.25 [DEBUG2] [calling.csa] debd7458: JoinConversationForCall [#566b2212-S] T#48651 S.25 [DEBUG2] [calling.csa] 566b2212: CIncomingConversationSetupOperation dcad8bf6-7218-4691-bda8-1a397b81b1e2 1 [#e93c4f82-S] T#48651 S.25 [DEBUG2] [calling.csa] e93c4f82: 708fb761-afee-46eb-8d09-89116ea40291 Call Connecting [#6f5d6b41-S] T#48651 S.25 [DEBUG2] [calling.csa] 6f5d6b41: 708fb761-afee-46eb-8d09-89116ea40291 ModalityStateChange [#debd7458-S] T#48651 S.25 [DEBUG2] [calling.csa] debd7458: Modality Call changed to state Connecting

callId: 708FB761-AFEE-46EB-8D09-89116EA40291, actionId: CE1CAA64-94E0-4583-860F-32CF9895A940 => Performing answer call action [#00000000-u] T#259 [DEBUG1] [ACSCallKitInternal.m] [ACSCallKitInternal][provider:performAnswerCallAction:]<0x283f0caa0>: callId: 708FB761-AFEE-46EB-8D09-89116EA40291, actionId: CE1CAA64-94E0-4583-860F-32CF9895A940 => Audio configuration: passed [#00000000-u] T#259 [DEBUG1] [ACSCallKitManager.m] [ACSCallKitManager][getIncomingCallInfo:]<0x2809bae80>: callId: 708FB761-AFEE-46EB-8D09-89116EA40291 => Get incoming call info: 0x0 [#00000000-u] T#259 [DEBUG1] [ACSCallKitInternal.m] [ACSCallKitInternal][acceptPendingIncomingCall:withCompletionHandler:]<0x283f0caa0>: callId: 708FB761-AFEE-46EB-8D09-89116EA40291, actionId: CE1CAA64-94E0-4583-860F-32CF9895A940 => Waiting for incoming call semaphore event to be raised

To Reproduce Steps to reproduce the behavior:

  1. Send incoming call context push notification to apns
  2. Receive push notification, report incoming call
  3. Set call agent delegate
  4. successfully handle push via call agent
  5. call agent delegate didRecieveIncomingCall not called

Code Snippet

func handleIncomingCall2(payload: PKPushPayload, completion: @escaping (() -> Void)){
        self.resetAzureCall()
        print("Call Manager handleIncomingCall")
        
        if let acsAccessToken = payload.dictionaryPayload["access_token"] as? String {
            print("Set Access token")
            print(acsAccessToken)
            Globals.acsAccessToken = acsAccessToken
            self.setUpCall()
        }
            
        let callNotification = PushNotificationInfo.fromDictionary(payload.dictionaryPayload)
        print("callNotification", callNotification.callId)

        
        let callKitOptions = CallKitOptions(with: CXProviderConfiguration())
        callKitOptions.configureAudioSession = self.configureAudioSession
        
        callKitOptions.provideRemoteInfo = self.provideCallKitRemoteInfo
        
        CallClient.reportIncomingCall(with: callNotification, callKitOptions: callKitOptions) { (error) in
            if error == nil {
                print("No error callProvider.reportNewIncomingCall")
                self.createCallAgent(displayName: "Mitch"){
                    self.callAgent?.delegate = self.acsCallAgentAdapter
                    if self.callAgent?.delegate == nil {
                        print("callAgent?.delegate not set")
                    }
                    
                    print("callNotification.eventType")
                    print(callNotification.eventType.rawValue)
                    
                    self.callAgent?.handlePush(notification: callNotification) { (error) in
                        if (error == nil) {
                            print("Handling of push notification was successful")
                        } else {
                            print("Handling of push notification failed")
                            print("error", error)
                            print("debugDescription", error.debugDescription)
                        }
                    }
                }
            }
            else{
                print("callProvider.reportNewIncomingCall failed")
            }
        }
    }
class AcsCallAgentAdapter: NSObject, CallAgentDelegate {
  func callAgent(_ callAgent: CallAgent, didRecieveIncomingCall incomingCall: IncomingCall) {
      print("didRecieveIncomingCall")
    // set up delegate and emit to React Native
  }

  func callAgent(_ callAgent: CallAgent, didUpdateCalls args: CallsUpdatedEventArgs) {
      print("didUpdateCalls")
  }
}

Code to get the incomingCallContext and format to send to apsn

$incomingCallContext = $data['incomingCallContext'];

$parts = explode('.', $incomingCallContext);
$part = utf8_decode(base64_decode(utf8_encode($parts[1])));

$request = [
       'callId' => $data['correlationId'],
       'videoCall' => false,
       'recipientId' => $data['to']['rawId'],
       'callerId' => $data['from']['rawId'],
       'displayName' => "Mitch",
       'eventId' => 107,
       'access_token' => $acsToken->access_token,
       'cp' => json_decode($part)->cc
];

Expected behavior Expecting didRecieveIncomingCall method to be called after call agent handle push

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: macOS 14.3.1
  • IDE : Xcode 15.3
  • AzureCommunicationCalling 2.8.0

Additional context I don't call register for push notifications on call agent as I am sending it from our backend when we receive the incoming call context based on this here

I'm not using the call kit integration on the call agent in this example but have tried that as well with the same issue.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x] Bug Description Added
  • [x] Repro Steps Added
  • [x] Setup information Added

MitchMooreVH avatar Mar 13 '24 14:03 MitchMooreVH