|
|
|
@ -6,20 +6,16 @@ import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
|
|
|
|
import 'package:mohem_flutter_app/app_state/app_state.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/consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/navigationService.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/navigationService.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/notifications.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
|
|
import 'package:mohem_flutter_app/main.dart';
|
|
|
|
import 'package:mohem_flutter_app/main.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/call.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/call.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as ALM;
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as ALM;
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/incoming_call_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart';
|
|
|
|
import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'package:signalr_netcore/hub_connection.dart';
|
|
|
|
import 'package:signalr_netcore/hub_connection.dart';
|
|
|
|
import 'package:signalr_netcore/signalr_client.dart';
|
|
|
|
import 'package:signalr_netcore/signalr_client.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -45,7 +41,7 @@ class ChatVoipCall {
|
|
|
|
// Online & App Logged In
|
|
|
|
// Online & App Logged In
|
|
|
|
ALM.Response sharedDetails = ALM.Response.fromJson(jsonDecode(await Utils.getStringFromPrefs("userLoginChatDetails")));
|
|
|
|
ALM.Response sharedDetails = ALM.Response.fromJson(jsonDecode(await Utils.getStringFromPrefs("userLoginChatDetails")));
|
|
|
|
autoLoginData = ALM.Response.fromJson(AppState().getchatUserDetails == null ? sharedDetails.toJson() : AppState().getchatUserDetails!.response!.toJson());
|
|
|
|
autoLoginData = ALM.Response.fromJson(AppState().getchatUserDetails == null ? sharedDetails.toJson() : AppState().getchatUserDetails!.response!.toJson());
|
|
|
|
dynamic items = jsonDecode(data!.data["user_chat_history_response"]);
|
|
|
|
dynamic items = jsonDecode(data.data["user_chat_history_response"]);
|
|
|
|
callerData = SingleUserChatModel(
|
|
|
|
callerData = SingleUserChatModel(
|
|
|
|
targetUserId: items["CurrentUserId"],
|
|
|
|
targetUserId: items["CurrentUserId"],
|
|
|
|
targetUserEmail: items["CurrentUserEmail"],
|
|
|
|
targetUserEmail: items["CurrentUserEmail"],
|
|
|
|
@ -58,7 +54,7 @@ class ChatVoipCall {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Offline or App in Background or App is At Verify Screen
|
|
|
|
// Offline or App in Background or App is At Verify Screen
|
|
|
|
autoLoginData = ALM.Response.fromJson(jsonDecode(data.data["user_token_response"]));
|
|
|
|
autoLoginData = ALM.Response.fromJson(jsonDecode(data.data["user_token_response"]));
|
|
|
|
callerData = SingleUserChatModel.fromJson(json.decode(data!.data["user_chat_history_response"]));
|
|
|
|
callerData = SingleUserChatModel.fromJson(json.decode(data.data["user_chat_history_response"]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CallKitParams params = CallKitParams(
|
|
|
|
CallKitParams params = CallKitParams(
|
|
|
|
id: uuid,
|
|
|
|
id: uuid,
|
|
|
|
@ -71,7 +67,7 @@ class ChatVoipCall {
|
|
|
|
textDecline: 'Decline',
|
|
|
|
textDecline: 'Decline',
|
|
|
|
textMissedCall: 'Missed call',
|
|
|
|
textMissedCall: 'Missed call',
|
|
|
|
textCallback: 'Call back',
|
|
|
|
textCallback: 'Call back',
|
|
|
|
extra: {"loginDetails": autoLoginData.toJson(), "callerDetails": callerData.toJson(), 'isIncomingCall': true, 'isUserOnline': isUserOnline, 'callType': data!.data["callType"]},
|
|
|
|
extra: {"loginDetails": autoLoginData.toJson(), "callerDetails": callerData.toJson(), 'isIncomingCall': true, 'isUserOnline': isUserOnline, 'callType': data.data["callType"]},
|
|
|
|
android: const AndroidParams(
|
|
|
|
android: const AndroidParams(
|
|
|
|
isCustomNotification: true,
|
|
|
|
isCustomNotification: true,
|
|
|
|
isShowLogo: false,
|
|
|
|
isShowLogo: false,
|
|
|
|
@ -210,10 +206,16 @@ class ChatVoipCall {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<HubConnection> makeHub() async {
|
|
|
|
Future<HubConnection> makeHub() async {
|
|
|
|
|
|
|
|
late HubConnection hc;
|
|
|
|
|
|
|
|
try {
|
|
|
|
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
|
|
|
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
|
|
|
HubConnection hc = HubConnectionBuilder()
|
|
|
|
hc = HubConnectionBuilder()
|
|
|
|
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${sessionData.extra!.loginDetails!.id}&source=Desktop&access_token=${sessionData.extra?.loginDetails!.token}", options: httpOp)
|
|
|
|
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${sessionData.extra!.loginDetails!.id}&source=Desktop&access_token=${sessionData.extra?.loginDetails!.token}", options: httpOp)
|
|
|
|
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
|
|
|
|
.withAutomaticReconnect(retryDelays: <int>[2000, 5000, 10000, 20000]).build();
|
|
|
|
return hc;
|
|
|
|
return hc;
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
print(e);
|
|
|
|
|
|
|
|
return hc;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|