Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
MitchMooreVH opened this issue Mar 13, 2024 · 7 comments
Assignees
Labels
Communication customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@MitchMooreVH
Copy link

MitchMooreVH commented Mar 13, 2024

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 13, 2024
@github-actions github-actions bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Mar 13, 2024
@tjprescott
Copy link
Member

@raosanat can you take a look?

@raosanat
Copy link
Member

Are you able to reproduce this 100% of the time ? Can you please check with the latest SDK 2.9.0 it will help us identifying the issue. We have added some more telemetry to help debug such issues.

@MitchMooreVH
Copy link
Author

Yeah it is happening 100% of the time. I also tried to send push notifications for an incoming call to the example repo here and had the same issue with the same message handle push successful but no call to the call agent delegate.

I'll try out 2.9.0 and see if it helps

@MitchMooreVH
Copy link
Author

MitchMooreVH commented Mar 25, 2024

I've update the sdk to 2.9.0, I'm still receiving the call kit incoming call. Everything is the same except callAgent handle push is no longer saying it was successful but it is also not producing an error.

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)
    }
}

However, I'm getting a new error:

Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 99 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 99 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}

And

nehelper sent invalid result code [1] for Wi-Fi information request.

I'm sure the app has wifi as I have it open and can refresh the content connected to my backend. I believe the first new error is from setting the call agent delegate because if I move it after callAgent handle push the first error does not appear. For signing capabilities I have both 'Background Fetch', 'Background Processing', and 'Voice over IP'

Not sure if it helps but the call id was 23F4BE7C-2C0C-4205-8324-EB88367CC6FF

@lucianopa-msft
Copy link
Contributor

lucianopa-msft commented Mar 28, 2024

@MitchMooreVH Can you provide a bit more info like createCallAgent function definition?

Also can you get the acs blog files from your application. They are located in the Cache directory, here is the way to access that folder https://forums.developer.apple.com/forums/thread/21660. Once there find all acs-*.blog and msrtc.*blog files as well.

@MitchMooreVH
Copy link
Author

Here is my createCallAgent function. I'll look into getting the blog files

func createCallAgent(displayName: String, completion: @escaping (() -> Void)){
        var callAgentOptions = CallAgentOptions()
        callAgentOptions.displayName = displayName
        
        self.callClient?.createCallAgent(userCredential: userCredential!, options: callAgentOptions) { (agent, error) in
            if error != nil {
                print("ERROR: It was not possible to create a call agent.")
                return
            }
            else {
                print("createdCallAgent")
                self.callAgent = agent
                completion()
            }
        }
        
        print("end createCallAgent")
    }

@lucianopa-msft
Copy link
Contributor

@MitchMooreVH Thank you for the info, also if possible a small project with basic setup that can repro the issue would help a lot. If not, the logs will already get us a more information to understand the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Communication customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants