Call Fixes

development_aamir
Aamir Muhammad 9 months ago
parent 109fb19d04
commit 185192e9a2

@ -1,9 +1,9 @@
import 'dart:async';
import 'dart:convert';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter_callkit_incoming/entities/entities.dart';
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
@ -29,6 +29,23 @@ class ChatVoipCall {
bool isUserOnline = false;
dynamic callData;
Timer? _timer;
int _start = 25;
void startTimer() {
Duration oneSec = const Duration(seconds: 1);
_timer = Timer.periodic(
oneSec,
(Timer timer) {
if (_start == 0) {
timer.cancel();
} else {
_start--;
}
},
);
}
Future<void> showCallkitIncoming({required String uuid, RemoteMessage? data, CallDataModel? incomingCallData, bool background = false}) async {
await FlutterCallkitIncoming.endAllCalls();
ALM.Response autoLoginData;
@ -94,8 +111,15 @@ class ChatVoipCall {
),
);
if (callerData.chatEventId == 3) {
startTimer();
await Utils.saveStringFromPrefs("isIncomingCall", "true");
await FlutterCallkitIncoming.showCallkitIncoming(params);
if (_start == 0) {
_timer!.cancel();
//await FlutterCallkitIncoming.showMissCallNotification(params);
await FlutterCallkitIncoming.endAllCalls();
}
}
}
@ -147,18 +171,18 @@ class ChatVoipCall {
// logger.log(Level.error, "API-EVENT-END");
}
Future<void> voipDeclineCall(IosCallPayload? iosCallPayload) async {
try {
print("DeclineVia Flutter");
print(iosCallPayload!.toRawJson());
IosCallPayload _iosCallPayload = IosCallPayload(incomingCallerId: iosCallPayload.incomingCallerId!.split("-")[0], incomingCallReciverId: iosCallPayload.incomingCallerId!.split("-")[1]);
ALM.UserAutoLoginModel model = await ChatApiClient().getUserCallToken(userid: iosCallPayload.incomingCallerId!.split("-")[1]);
await ChatApiClient()
.callDecline(cUserID: int.parse(_iosCallPayload.incomingCallerId!), tUserID: int.parse(_iosCallPayload.incomingCallReciverId.toString()), targetUsertoken: model.response!.token);
} catch (err) {
print(err);
}
}
// Future<void> voipDeclineCall(IosCallPayload? iosCallPayload) async {
// try {
// print("DeclineVia Flutter");
// print(iosCallPayload!.toRawJson());
// IosCallPayload _iosCallPayload = IosCallPayload(incomingCallerId: iosCallPayload.incomingCallerId!.split("-")[0], incomingCallReciverId: iosCallPayload.incomingCallerId!.split("-")[1]);
// ALM.UserAutoLoginModel model = await ChatApiClient().getUserCallToken(userid: iosCallPayload.incomingCallerId!.split("-")[1]);
// await ChatApiClient()
// .callDecline(cUserID: int.parse(_iosCallPayload.incomingCallerId!), tUserID: int.parse(_iosCallPayload.incomingCallReciverId.toString()), targetUsertoken: model.response!.token);
// } catch (err) {
// print(err);
// }
// }
Future<HubConnection> makeHub({required IncomingCallModel sessionData}) async {
late HubConnection hc;

@ -1,9 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:just_audio/just_audio.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
@ -26,6 +28,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
RTCVideoRenderer? remoteRenderer;
final AudioPlayer player = AudioPlayer();
final FlutterIOSVoIPKit voIPKit = FlutterIOSVoIPKit.instance;
MediaStream? _localStream;
late CallDataModel outGoingCallData;
bool isMicOff = false;
@ -46,8 +49,6 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
late BuildContext providerContext;
List<MediaDeviceInfo> devices = [];
void initCallListeners({required BuildContext context}) {
providerContext = context;
if (kDebugMode) {
@ -58,7 +59,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
chatHubConnection!.on("OnOfferAsync", onOfferAsync);
chatHubConnection!.on("OnAnswerOffer", onAnswerOffer);
chatHubConnection!.on("OnHangUpAsync", onHangUpAsync);
// chatHubConnection!.on("OnCallDeclinedAsync", onCallDeclinedAsync);
chatHubConnection!.on("OnCallDeclinedAsync", onCallDeclinedAsync);
// chatHubConnection!.on("OnIncomingCallAsync", OnIncomingCallAsync);
}
@ -121,6 +122,10 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// OutGoing Listeners
void onCallAcceptedAsync(List<Object?>? params) async {
if (_timer!.isActive && _start > 5) {
_timer!.cancel();
_start = 25;
}
dynamic items = params!.toList();
RTCSessionDescription description = await _createOffer();
await _pc.setLocalDescription(description);
@ -232,7 +237,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
if (chatHubConnection != null && !isUserOnline) {
chatHubConnection!.stop();
}
await FlutterCallkitIncoming.endAllCalls();
if (Platform.isAndroid) await FlutterCallkitIncoming.endAllCalls();
if (Platform.isIOS) await voIPKit.endCall();
return true;
} else {
if (isOutGoingCall) {
@ -289,28 +295,24 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// }
}
void onHangUpAsync(List<Object?>? params) {
Future<void> onHangUpAsync(List<Object?>? params) async {
print("--------------------- onHangUp ASYNC ---------------------------------");
dynamic items = params!.toList();
// if (kDebugMode) {
// logger.i("res: " + items.toString());
// }
if (items[0]["id"] != AppState().chatDetails!.response!.id) {
if (kDebugMode) {
print("Call Ended By Other User");
}
if (Platform.isIOS) await voIPKit.endCall();
if (Platform.isAndroid) await FlutterCallkitIncoming.endAllCalls();
if (isIncomingCall) {
endCall(isUserOnline: isUserOnline).then((bool value) {
if (isCallConnected && isUserOnline) {
isCallConnected = false;
if (!AppState().isLogged) {
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
Navigator.of(AppRoutes.navigatorKey.currentContext!).canPop();
} else {
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.dashboard));
}
} else {
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
Navigator.of(AppRoutes.navigatorKey.currentContext!).canPop();
}
});
} else {
@ -320,7 +322,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
isCallConnected = false;
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.dashboard));
} else {
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
// Navigator.of(AppRoutes.navigatorKey.currentContext!).canPop();
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.dashboard));
}
});
}
@ -330,11 +333,20 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
print("Call Ended By Me");
}
if (isOutGoingCall) {
// if (!isCallConnected) {
// if (_timer!.isActive && _start == 5) {
// _timer!.cancel();
// _start = 25;
// Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
// endCall(isUserOnline: isUserOnline);
// return Utils.showToast("${items[0]["userName"]}" + " has declined call", longDuration: true);
// }
// }
if (isCallConnected && isUserOnline) {
isCallConnected = false;
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
} else {
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
Navigator.of(AppRoutes.navigatorKey.currentContext!).canPop();
}
}
}
@ -363,6 +375,43 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// });
}
//Outgoing Timer for Decline Call
Timer? _timer;
int _start = 25;
void startTimer() {
Duration oneSec = const Duration(seconds: 1);
_timer = Timer.periodic(
oneSec,
(Timer timer) {
if (_start == 0) {
timer.cancel();
} else {
print(_start);
_start--;
if (isOutGoingCall) {
if (!isCallConnected) {
if (_timer!.isActive && _start == 5) {
_timer!.cancel();
_start = 25;
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
endCall(isUserOnline: isUserOnline);
return Utils.showToast("${outGoingCallData.receiverName}" + " has declined call", longDuration: true);
}
} else {
if (isCallConnected) {
_timer!.cancel();
_start = 25;
}
}
notifyListeners();
}
}
},
);
}
// Future<void> OnIncomingCallAsync(List<Object?>? params) async {
// print("--------------------- On Incoming Call ---------------------------------------");
// dynamic items = params!.toList();
@ -413,24 +462,16 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
// // }
// }
void onCallDeclinedAsync(List<Object?>? params) {
print("================= On Declained ========================");
logger.d(params);
// endCall().then((bool value) {
// if (value) {
// isCallEnded = true;
// notifyListeners();
// }
// });
// if (params != null) {
// endCall(isUserOnline: isUserOnline).then((bool value) {
// if (isCallConnected) {
// // Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
// isCallConnected = false;
// }
// isCallEnded = true;
// });
// }
Future<void> onCallDeclinedAsync(List<Object?>? params) async {
print("================= On Declined ========================");
dynamic items = params!.toList();
if (isOutGoingCall) {
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
bool val = await endCall(isUserOnline: isUserOnline);
if (Platform.isIOS) await voIPKit.endCall();
if (Platform.isAndroid) await FlutterCallkitIncoming.endAllCalls();
return Utils.showToast("${items[1]["userName"]}" + " has declined call", longDuration: true);
}
}
//// Invoke Methods

@ -156,22 +156,24 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
void registerEvents() {
chatHubConnection!.on("OnUpdateUserStatusAsync", changeStatus);
// chatHubConnection!.on("OnDeliveredChatUserAsync", onMsgReceived);
chatHubConnection!.on("OnSubmitChatAsync", OnSubmitChatAsync);
chatHubConnection!.on("OnUserTypingAsync", onUserTyping);
chatHubConnection!.on("OnUserCountAsync", userCountAsync);
// chatHubConnection!.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
chatHubConnection!.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
chatHubConnection!.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
chatHubConnection!.on("OnGetGroupUserStatusAsync", getGroupUserStatus);
chatHubConnection!.on("OnAddGroupChatHistoryAsync", groupChatHistoryAsync);
//
// {"type":1,"target":"","arguments":[[{"id":217869,"userName":"Sultan.Khan","email":"Sultan.Khan@cloudsolutions.com.sa","phone":null,"title":"Sultan.Khan","userStatus":1,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":false,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null},{"id":15153,"userName":"Tamer.Fanasheh","email":"Tamer.F@cloudsolutions.com.sa","phone":null,"title":"Tamer Fanasheh","userStatus":2,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":true,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null}]]}
if (chatHubConnection != null) {
chatHubConnection!.on("OnUpdateUserStatusAsync", changeStatus);
// chatHubConnection!.on("OnDeliveredChatUserAsync", onMsgReceived);
chatHubConnection!.on("OnSubmitChatAsync", OnSubmitChatAsync);
chatHubConnection!.on("OnUserTypingAsync", onUserTyping);
chatHubConnection!.on("OnUserCountAsync", userCountAsync);
// chatHubConnection!.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
chatHubConnection!.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
chatHubConnection!.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
chatHubConnection!.on("OnGetGroupUserStatusAsync", getGroupUserStatus);
chatHubConnection!.on("OnAddGroupChatHistoryAsync", groupChatHistoryAsync);
//
// {"type":1,"target":"","arguments":[[{"id":217869,"userName":"Sultan.Khan","email":"Sultan.Khan@cloudsolutions.com.sa","phone":null,"title":"Sultan.Khan","userStatus":1,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":false,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null},{"id":15153,"userName":"Tamer.Fanasheh","email":"Tamer.F@cloudsolutions.com.sa","phone":null,"title":"Tamer Fanasheh","userStatus":2,"image":null,"unreadMessageCount":0,"userAction":3,"isPin":false,"isFav":false,"isAdmin":true,"rKey":null,"totalCount":0,"isHuaweiDevice":false,"deviceToken":null}]]}
if (kDebugMode) {
logger.i("All listeners registered");
if (kDebugMode) {
logger.i("All listeners registered");
}
}
}

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/models/chat/call.dart';
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
@ -33,14 +34,7 @@ class _OutGoingCallState extends State<OutGoingCall> {
Future<void> init() async {
widget.isVideoCall ? callProvider.isVideoCall = true : callProvider.isVideoCall = false;
callProvider.isOutGoingCall = true;
// IosCallPayload payload = IosCallPayload(
// incomingCallerId: widget.outGoingCallData.callerId.toString(),
// incomingCallerName: widget.outGoingCallData.callerName,
// incomingCallReciverId: widget.outGoingCallData.receiverId.toString(),
// incomingCallType: widget.outGoingCallData.callType,
// uuid: "",
// callData: widget.outGoingCallData.toRawJson());
// await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(payload));
callProvider.startTimer();
await callProvider.initLocalCamera(chatProvmodel: chatProvider, callData: widget.outGoingCallData, context: context);
loader = false;
}
@ -57,10 +51,6 @@ class _OutGoingCallState extends State<OutGoingCall> {
init();
return Scaffold(
body: Consumer<ChatCallProvider>(builder: (BuildContext context, ChatCallProvider chatcp, Widget? child) {
// if (chatcp.isCallEnded) {
// Navigator.pop(context);
// }
return loader
? const Center(
child: CircularProgressIndicator(),
@ -159,15 +149,13 @@ class _OutGoingCallState extends State<OutGoingCall> {
onPressed: () {
chatcp.endCall(isUserOnline: chatProvider.isUserOnline).then((bool value) {
if (value) {
Navigator.of(context).pop();
Navigator.of(context).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
}
});
},
elevation: 2.0,
fillColor: MyColors.redA3Color,
padding: const EdgeInsets.all(
15.0,
),
padding: const EdgeInsets.all(15.0),
shape: const CircleBorder(),
child: const Icon(
Icons.call_end,

@ -18,6 +18,7 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/main.dart';
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
import 'package:mohem_flutter_app/models/itg/itg_main_response.dart';
import 'package:mohem_flutter_app/models/itg/itg_response_model.dart';
import 'package:mohem_flutter_app/models/offers_and_discounts/get_offers_list.dart';
@ -90,8 +91,10 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
}
break;
case Event.actionCallDecline:
SingleUserChatModel callerData;
Utils.saveStringFromPrefs("isIncomingCall", "false");
Utils.saveStringFromPrefs("inComingCallData", "null");
declineCall(cuserid: event.body["extra"]["callerDetails"]["currentUserId"], ruserid: event.body["extra"]["callerDetails"]["targetUserId"]);
FlutterCallkitIncoming.endAllCalls();
break;
@ -110,6 +113,18 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
} on Exception {}
}
void declineCall({required int cuserid, required int ruserid}) async {
logger.i("-----------------------Call Decline Hit---------------------------");
if (chatHubConnection!.state == HubConnectionState.Connected) {
try {
await chatHubConnection!.invoke("CallDeclinedAsync", args: <Object>[cuserid, ruserid]);
await chatHubConnection!.invoke("UpdateUserStatusAsync", args: <Object>[cuserid, 1]);
} catch (e) {
logger.w(e);
}
}
}
Future<void> moveToCallScreen() async {
dynamic calls = await FlutterCallkitIncoming.activeCalls();
if (calls is List) {

@ -18,7 +18,6 @@ import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
// import 'package:huawei_hmsavailability/huawei_hmsavailability.dart';
import 'package:mohem_flutter_app/api/login_api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/chat_call_kit.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/classes/notifications.dart';
@ -38,6 +37,7 @@ import 'package:mohem_flutter_app/models/privilege_list_model.dart';
import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart';
import 'package:signalr_netcore/hub_connection.dart';
import 'package:wifi_iot/wifi_iot.dart';
class LoginScreen extends StatefulWidget {
@ -111,10 +111,8 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
voIPKit.onDidReceiveIncomingPush = (
Map<String, dynamic> payload,
) async {
print("🎈 Call Payload Incoming Push:");
print(payload);
_iosCallPayload = IosCallPayload.fromJson(payload);
_timeOut();
_timeOut(callDetails: _iosCallPayload!.incomingCallerId!);
};
voIPKit.onDidRejectIncomingCall = (
@ -122,7 +120,10 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
String callerId,
) async {
timeOutTimer.cancel();
await ChatVoipCall().voipDeclineCall(_iosCallPayload);
declineCall(
cuserid: int.parse(callerId.split("-")[1]),
ruserid: int.parse(callerId.split("-")[0]),
);
await voIPKit.endCall();
};
@ -133,19 +134,18 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
await connectCall(uuid: uuid, callDetails: callerId);
voIPKit.acceptIncomingCall(callerState: CallStateType.calling);
voIPKit.callConnected().then((value) => timeOutTimer.cancel());
// Utils.showToast("Timer Cancel", longDuration: true);
};
}
void _timeOut() async {
timeOutTimer = Timer(const Duration(seconds: 20), () async {
void _timeOut({required String callDetails}) async {
timeOutTimer = Timer(const Duration(seconds: 25), () async {
String? incomingCallerName = await voIPKit.getIncomingCallerName();
voIPKit.unansweredIncomingCall(
skipLocalNotification: false,
skipLocalNotification: true,
missedCallTitle: '📞 Missed call',
missedCallBody: 'There was a call from $incomingCallerName',
);
await ChatVoipCall().voipDeclineCall(_iosCallPayload);
declineCall(cuserid: int.parse(callDetails.split("-")[1]), ruserid: int.parse(callDetails.split("-")[0]));
await voIPKit.endCall();
});
}
@ -163,39 +163,36 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
_iosCallPayload = IosCallPayload(
uuid: uuid, incomingCallerId: callDetails.split("-")[0], incomingCallReciverId: callDetails.split("-")[1], incomingCallerName: null, incomingCallType: callDetails.split("-").last);
}
// _iosCallPayload = IosCallPayload(uuid: "3423434-423423-43-53-5", incomingCallerId: "266642", incomingCallReciverId: "341682", incomingCallerName: null, incomingCallType: "video");
print("🎈 Call Payload callDetails:" + callDetails);
print("🎈 Call Payload Before:" + _iosCallPayload!.toRawJson());
if (_iosCallPayload!.incomingCallerName == null) {
if (Platform.isIOS) {
Utils.hideLoading(context);
}
// await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(_iosCallPayload));
// Utils.showToast("Name Null", longDuration: true);
if (Platform.isIOS) {
Future.delayed(Duration(seconds: 3), () async {
MaterialPageRoute pageRoute = await MaterialPageRoute(
builder: (BuildContext context) => StartCallPage(
payload: _iosCallPayload,
));
builder: (BuildContext context) => StartCallPage(
payload: _iosCallPayload,
),
);
Navigator.push(context, pageRoute);
});
}
} else if (AppState().getisUserOnline) {
// await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(_iosCallPayload));
BuildContext context = AppRoutes.navigatorKey.currentContext!;
if (Platform.isIOS) {
Future.delayed(Duration(seconds: 3), () async {
MaterialPageRoute pageRoute = await MaterialPageRoute(
builder: (BuildContext context) => StartCallPage(
payload: _iosCallPayload,
));
builder: (BuildContext context) => StartCallPage(
payload: _iosCallPayload,
),
);
Navigator.push(context, pageRoute);
});
}
} else {
FlutterCallkitIncoming.endAllCalls();
if (Platform.isAndroid) FlutterCallkitIncoming.endAllCalls();
if (Platform.isIOS) await voIPKit.endCall();
Utils.showToast("Something wen't wrong");
}
}
@ -233,6 +230,7 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
case Event.actionCallDecline:
Utils.saveStringFromPrefs("isIncomingCall", "false");
Utils.saveStringFromPrefs("inComingCallData", "null");
declineCall(cuserid: event.body["extra"]["callerDetails"]["currentUserId"], ruserid: event.body["extra"]["callerDetails"]["targetUserId"]);
FlutterCallkitIncoming.endAllCalls();
break;
@ -247,13 +245,25 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver {
FlutterCallkitIncoming.endAllCalls();
break;
}
print('${event.toString()}\n');
print('${event.body}\n');
});
} on Exception {
logger.log(Level.info, "EXCEPTION-ON-EVENTS");
}
}
void declineCall({required int cuserid, required int ruserid}) async {
logger.i("-----------------------Call Decline Hit---------------------------");
if (chatHubConnection!.state == HubConnectionState.Connected) {
try {
await chatHubConnection!.invoke("CallDeclinedAsync", args: <Object>[cuserid, ruserid]);
await chatHubConnection!.invoke("UpdateUserStatusAsync", args: <Object>[cuserid, 1]);
} catch (e) {
logger.w(e);
}
}
}
Future<void> moveToCallScreen() async {
dynamic calls = await FlutterCallkitIncoming.activeCalls();
if (calls is List) {

@ -115,8 +115,8 @@ class _DeleteFamilyMemberState extends State<DeleteFamilyMember> {
padding: EdgeInsets.only(left: 50, right: 50),
child: TextButton(
style: TextButton.styleFrom(
primary: MyColors.white,
onSurface: MyColors.white,
foregroundColor: MyColors.white,
disabledForegroundColor: MyColors.white,
backgroundColor: MyColors.gradiantEndColor,
),
onPressed: () {

Loading…
Cancel
Save