Search code examples
androidazureazure-communication-services

Azure Communication Services - incoming call when app is closed


I'm using ACS (Azure Communication Services) to run a video/audio call between two devices, the receiving device is Android based.

There are 3 scenarios -

  1. The App in the receiving device is open and in the foreground
  2. The App in the receiving device is open and in the background
  3. The App is closed in the Receiving Device

I wired ACS to EventGrid and from there to an Azure function that uses Azure push notifications and I can get an incomingCall push notification to the device with custom detail.

Scenarios 1 and 2 work very well now - the push notification is received and I use that to bring the app to foreground (if not already) and activate the incoming call behaviour

With scenario 3 - I open the app, which then creates the Call Agent and Call Client and add listeners using both addOnCallsUpdatedListener and addOnIncomingCallListener, but they don't seem to get fired, presumably because this happens AFTER the call had been started.

I'm guessing one workaround would be to change the bahviour from calling from A->B to starting a call and using push notification to get B to join the call, but before I make this change I wanted to know if there are better ideas


Solution

  • The answer is to wire ACS directly to Notification Hub which can then deliver a specifically structued notification to the app. When the app received the notification, instantiate the callAgent and call

    callAgent.handlePushNotification(pushNotificationInfo);
    

    where pushNotificationInfo is the Map<String,String> delivered with the push notification from ACS. the function then invokes the callAgent incomingCallListener

    Documentation can be found here