From 2f3629b6efc6cc8816efa7cd985832646f91f841 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Thu, 8 Oct 2026 10:29:34 +0300 Subject: [PATCH] huawei token fixed --- .../cx_module/chat/calling/call_provider.dart | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/modules/cx_module/chat/calling/call_provider.dart b/lib/modules/cx_module/chat/calling/call_provider.dart index 23e1adef..6252e3fd 100644 --- a/lib/modules/cx_module/chat/calling/call_provider.dart +++ b/lib/modules/cx_module/chat/calling/call_provider.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:signalr_netcore/http_connection_options.dart'; @@ -51,13 +52,14 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin { currentStatus = status; notifyListeners(); } + void _startCallDurationTimer() { _callDurationTimer?.cancel(); callDuration = Duration.zero; _callDurationTimer = Timer.periodic( const Duration(seconds: 1), - (_) { + (_) { callDuration = Duration( seconds: callDuration.inSeconds + 1, ); @@ -65,6 +67,7 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin { }, ); } + Future _disposeConnection() async { final HubConnection? connection = callHubConnection; final bool owns = _ownsConnection; @@ -147,6 +150,7 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin { final String query = uri.query.isEmpty ? '' : '?${uri.query}'; return '${uri.scheme}://${uri.host}:$port${uri.path}$query'; } + String get formattedCallDuration { final hours = callDuration.inHours; final minutes = callDuration.inMinutes.remainder(60); @@ -214,10 +218,20 @@ class CallProvider with ChangeNotifier, DiagnosticableTreeMixin { if (kDebugMode) print('Shared chat hub not usable (state: ${hubC.state}), opening a dedicated call connection.'); } await _disposeConnection(); - + String platform; + if (Platform.isIOS) { + platform = "IOS"; + } else { + if (await FirebaseNotificationManger.isGoogleServicesAvailable()) { + platform = "GOOGLE"; + } else { + platform = "HUAWEI"; + } + } + bool isHuaweiDevice() => platform == "HUAWEI"; final http.Response response = await ApiClient().postJsonForResponse( URLs.chatSdkToken, - {"apiKey": URLs.chatApiKey, "employeeNumber": employeeNumber, "voIPToken": FirebaseNotificationManger.voipToken}, + {"apiKey": URLs.chatApiKey, "employeeNumber": employeeNumber, "isHuaweiDevice": isHuaweiDevice(), "platform": platform, "voIPToken": FirebaseNotificationManger.voipToken}, ); if (response.statusCode != 200) { if (kDebugMode) print('Call token request failed: HTTP ${response.statusCode}');