Changes On iOS

merge-requests/188/head
Aamir Muhammad 2 years ago
parent aed4a9602b
commit 39bcf5c3d9

@ -29,7 +29,6 @@ class ChatVoipCall {
ChatVoipCall._internal();
factory ChatVoipCall() => _instance;
late ChatProviderModel prov;
late ChatCallProvider cProv;
dynamic inCallData;
@ -72,13 +71,7 @@ class ChatVoipCall {
textDecline: 'Decline',
textMissedCall: 'Missed call',
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(
isCustomNotification: true,
isShowLogo: false,
@ -179,9 +172,11 @@ class ChatVoipCall {
}
Future<void> declineCall() async {
if (isUserOnline && chatHubConnection != null) {
if (isUserOnline) {
HubConnection hc = await makeHub();
await hc.start();
print("Connection State ===" + chatHubConnection.state.toString());
if (chatHubConnection.state == HubConnectionState.Connected) {
if (hc.state == HubConnectionState.Connected) {
if (sessionData?.extra != null) {
chatHubConnection.invoke("HangUpAsync", args: [
int.parse(sessionData.extra!.callerDetails!.currentUserId.toString()),
@ -191,15 +186,12 @@ class ChatVoipCall {
int.parse(sessionData.extra!.callerDetails!.currentUserId.toString()),
1,
]);
FlutterCallkitIncoming.endCall(sessionData.id!);
chatHubConnection = hc;
}
}
} else {
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
HubConnection hc = HubConnectionBuilder()
.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();
HubConnection hc = await makeHub();
await hc.start();
await hc.invoke(
"HangUpAsync",
@ -216,4 +208,12 @@ class ChatVoipCall {
}
}
}
Future<HubConnection> makeHub() async {
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
HubConnection hc = HubConnectionBuilder()
.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();
return hc;
}
}

@ -18,6 +18,7 @@ final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterL
class AppNotifications {
static final AppNotifications _instance = AppNotifications._internal();
AppNotifications._internal();
factory AppNotifications() => _instance;
@ -46,7 +47,6 @@ class AppNotifications {
// if (Platform.isAndroid) {
// hmsApiAvailability = HmsApiAvailability();
// }
await requestPermissions();
AppState().setDeviceToken = firebaseToken;
await Permission.notification.isDenied.then((bool value) {
@ -135,12 +135,9 @@ class AppNotifications {
}
}
Future<dynamic> backgroundMessageHandler(RemoteMessage message) async {
//await Firebase.initializeApp();
await Firebase.initializeApp();
print("res: ------background message--------");
logger.w(message);
if (message.data.isNotEmpty && message.data["messageType"] == 'chat') {
Utils.saveStringFromPrefs("isAppOpendByChat", "false");
Utils.saveStringFromPrefs("notificationData", message.data["user_chat_history_response"].toString());

Loading…
Cancel
Save