-
Notifications
You must be signed in to change notification settings - Fork 6
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
Not able to decline the call when app in Background Mode #113
Comments
In order to decline a notification you need to log into the socket and send a bye message for that invite with the call ID. This means to actually decline a call from a push notification you need to reconnect to the socket, log in with a stored credential, send a bye message, and disconnect again. You can see a sample implementation of this here in main.dart, however there are definite improvements that can be made here for a production application (remember the sample is just a simple usage example) case Event.actionCallDecline:
/*
* When the user declines the call from the push notification, the app will no longer be visible, and we have to
* handle the endCall user here.
*
* */
logger.i('actionCallDecline :: call declined');
String? token;
PushMetaData? pushMetaData;
final telnyxClient = TelnyxClient();
telnyxClient.onSocketMessageReceived = (TelnyxMessage message) {
switch (message.socketMethod) {
case SocketMethod.bye:
{
// make sure to disconnect the telnyxclient on Bye for Decline
// Only disconnect the socket when the call was ended from push notifications
logger.i('TelnyxClient :: onSocketMessageReceived :: BYE');
telnyxClient.disconnect();
break;
}
default:
logger.i('TelnyxClient :: onSocketMessageReceived $message');
}
logger.i('TelnyxClient :: onSocketMessageReceived : $message');
};
pushMetaData =
PushMetaData.fromJson(jsonDecode(message.data['metadata']!));
// Set the pushMetaData to decline
pushMetaData.isDecline = true;
if (defaultTargetPlatform == TargetPlatform.android) {
token = (await FirebaseMessaging.instance.getToken())!;
logger.i('Android notification token :: $token');
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
token = await FlutterCallkitIncoming.getDevicePushTokenVoIP();
logger.i('iOS notification token :: $token');
}
final config = await txClientViewModel.getConfig();
telnyxClient.handlePushNotification(
pushMetaData,
config is CredentialConfig ? config : null,
config is TokenConfig ? config : null,
);
break; |
@Oliver-Zimmerman This method I can see in firebase Background handler , but when app is in background , AND from Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {}
You can see a sample implementation of this here in main.dart, however there are definite improvements that can be made here for a production application (remember the sample is just a simple usage example) |
@Kushagra-Esmagico I cannot reproduce your issue on our sample app. Here is another demonstration video of being able to decline a call when the app isn't open or when it is in the background... You can see we receive the User Busy state which is only emitted when a user declines a call. Screen.Recording.2025-02-26.at.09.52.29.mov |
Bug Category**
SDK Version
Which version of the SDK have you added from pub.dev? Feel free to add the whole dependency implementation:
eg. telnyx_webrtc: ^1.0.2
Describe the bug
When App is in background and got the call notification , try to decline the call , it does not decline the call , and when call is time out , getting another call notification
Expected behaviour
When user click on Decline call, It should end the call and on other end , the call should be disconnected . Duplicate call notification should not be there
Observation
When app is in background and user decline it , it is invoking both FlutterCallkitIncoming.onEvent.listen from initialize method and firebase background handler , if it declines the call , on next inbound call , that is automatically ended , as we have called the endcall method two times from both listeners .
To Reproduce
Steps to reproduce the behaviour:
2 Make the app in background , it disconnects the socket.
** Device (please complete the following information):**
Logs
The text was updated successfully, but these errors were encountered: