admin管理员组

文章数量:1122846

I am trying to implement audio call in my react native app using azure communication calling sdk. When app is in the foreground AND the IncomingCallListener is setup BEFORE a call is initiated it works fine. But when a call is initiated first and then the IncomingCallListener is setup in the receiver device, the incoming call is never received. I learned from that i am supposed to handle this situation by registering for push notifications. So i setup incoming call push notification (voip for iOS) in server. When incoming call is initiated, i get an event webhook from Azure event grid. But azure calling sdk expects the payload of this notification in a very specific format which is not exposed inside the sdk code.

So unless i know what the format is i cant fix this incoming call issue. Can anyone help me understand what the payload format should be? NB: I also tried using azure notification hub combined with azure notification in order to receive incoming call push payload directly from azure. I can see in the notification hub metrics that notifications always fail with this error message FCMv1 Authorization Errors Here is my code to handle the incoming call data payload.

public void setUpIncomingCall(Map<String, String> map, String acsToken, String displayName, Context context) {
        try{
            if (callAgent == null) {
                CallAgentOptions callAgentOptions = new CallAgentOptions();
                callAgentOptions.setDisplayName(displayName);


                callClient.createCallAgent(context, new CommunicationTokenCredential(acsToken), callAgentOptions).thenAccept(callAgent1 -> {
                    callAgent = callAgent1;

                    Log.e("incomingCall","created call agent");

                    incomingCallListener = new IncomingCallListener() {
                        @Override
                        public void onIncomingCall(IncomingCall incomingCall) {
                            Log.e("setUpIncomingCall", "Incoming call received");
                            currentIncomingCall = incomingCall;
                        }
                    };
                    callAgent.addOnIncomingCallListener(incomingCallListener);

                    PushNotificationInfo pushNotificationInfo = PushNotificationInfo.fromMap(map);

                    if (pushNotificationInfo != null) {
                        callAgent.handlePushNotification(pushNotificationInfo).thenAccept(aVoid -> {
                            Log.e("handleCallPush", "Push payload mapping success");
                        }).exceptionally(throwable -> {
                            throwable.printStackTrace();
                            Log.e("handleCallPush", "Failed to handleCallPush", throwable);
                            return null;
                        });
                    } else {
                        Log.e("incomingCall","incomingCall error pushNotificationInfo null");
                    }



                }).exceptionally(throwable -> {
                    Log.e("incomingCall", "setUpIncomingCall error", throwable);
                    return null;
                });
            }
            else {
                Log.e("incomingCall","existing call agent");
                incomingCallListener = new IncomingCallListener() {
                    @Override
                    public void onIncomingCall(IncomingCall incomingCall) {
                        Log.e("setUpIncomingCall", "Incoming call received");
                        currentIncomingCall = incomingCall;
                    }
                };
                callAgent.addOnIncomingCallListener(incomingCallListener);

                PushNotificationInfo pushNotificationInfo = PushNotificationInfo.fromMap(map);

                if (pushNotificationInfo != null) {
                    callAgent.handlePushNotification(pushNotificationInfo).thenAccept(aVoid -> {
                        Log.e("handleCallPush", "Push payload mapping success");
                    }).exceptionally(throwable -> {
                        throwable.printStackTrace();
                        Log.e("handleCallPush", "Failed to handleCallPush", throwable);
                        return null;
                    });
                } else {
                    Log.e("incomingCall","incomingCall error pushNotificationInfo null");
                }
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            Log.e("setUpIncomingCall", "setUpIncomingCall error", exception);
        }

    }

I am trying to implement audio call in my react native app using azure communication calling sdk. When app is in the foreground AND the IncomingCallListener is setup BEFORE a call is initiated it works fine. But when a call is initiated first and then the IncomingCallListener is setup in the receiver device, the incoming call is never received. I learned from https://learn.microsoft.com/en-us/azure/communication-services/how-tos/calling-sdk/push-notifications?pivots=platform-android that i am supposed to handle this situation by registering for push notifications. So i setup incoming call push notification (voip for iOS) in .net server. When incoming call is initiated, i get an event webhook from Azure event grid. But azure calling sdk expects the payload of this notification in a very specific format which is not exposed inside the sdk code.

So unless i know what the format is i cant fix this incoming call issue. Can anyone help me understand what the payload format should be? NB: I also tried using azure notification hub combined with azure notification in order to receive incoming call push payload directly from azure. I can see in the notification hub metrics that notifications always fail with this error message FCMv1 Authorization Errors Here is my code to handle the incoming call data payload.

public void setUpIncomingCall(Map<String, String> map, String acsToken, String displayName, Context context) {
        try{
            if (callAgent == null) {
                CallAgentOptions callAgentOptions = new CallAgentOptions();
                callAgentOptions.setDisplayName(displayName);


                callClient.createCallAgent(context, new CommunicationTokenCredential(acsToken), callAgentOptions).thenAccept(callAgent1 -> {
                    callAgent = callAgent1;

                    Log.e("incomingCall","created call agent");

                    incomingCallListener = new IncomingCallListener() {
                        @Override
                        public void onIncomingCall(IncomingCall incomingCall) {
                            Log.e("setUpIncomingCall", "Incoming call received");
                            currentIncomingCall = incomingCall;
                        }
                    };
                    callAgent.addOnIncomingCallListener(incomingCallListener);

                    PushNotificationInfo pushNotificationInfo = PushNotificationInfo.fromMap(map);

                    if (pushNotificationInfo != null) {
                        callAgent.handlePushNotification(pushNotificationInfo).thenAccept(aVoid -> {
                            Log.e("handleCallPush", "Push payload mapping success");
                        }).exceptionally(throwable -> {
                            throwable.printStackTrace();
                            Log.e("handleCallPush", "Failed to handleCallPush", throwable);
                            return null;
                        });
                    } else {
                        Log.e("incomingCall","incomingCall error pushNotificationInfo null");
                    }



                }).exceptionally(throwable -> {
                    Log.e("incomingCall", "setUpIncomingCall error", throwable);
                    return null;
                });
            }
            else {
                Log.e("incomingCall","existing call agent");
                incomingCallListener = new IncomingCallListener() {
                    @Override
                    public void onIncomingCall(IncomingCall incomingCall) {
                        Log.e("setUpIncomingCall", "Incoming call received");
                        currentIncomingCall = incomingCall;
                    }
                };
                callAgent.addOnIncomingCallListener(incomingCallListener);

                PushNotificationInfo pushNotificationInfo = PushNotificationInfo.fromMap(map);

                if (pushNotificationInfo != null) {
                    callAgent.handlePushNotification(pushNotificationInfo).thenAccept(aVoid -> {
                        Log.e("handleCallPush", "Push payload mapping success");
                    }).exceptionally(throwable -> {
                        throwable.printStackTrace();
                        Log.e("handleCallPush", "Failed to handleCallPush", throwable);
                        return null;
                    });
                } else {
                    Log.e("incomingCall","incomingCall error pushNotificationInfo null");
                }
            }
        } catch (Exception exception) {
            exception.printStackTrace();
            Log.e("setUpIncomingCall", "setUpIncomingCall error", exception);
        }

    }
Share Improve this question edited Nov 22, 2024 at 11:19 Fahim Jubayer asked Nov 22, 2024 at 11:14 Fahim JubayerFahim Jubayer 33 bronze badges 1
  • This post mentions the same issue but i dont understand how the issue was fixed. stackoverflow.com/questions/76338124/… – Fahim Jubayer Commented Nov 22, 2024 at 11:18
Add a comment  | 

1 Answer 1

Reset to default 0

I found the payload format here in this link

https://github.com/Azure-Samples/azure-communication-services-calling-event-grid/blob/main/add-calling-push-notifications-event-grid/ACSCallingNativeRegistrarLite/Utilities/Utilities.cs

We ended up not using notification hub and implemented push delivery logic in our own server. After including the data required in the payload incoming calls were successfully being received.

本文标签: