update device token/platform for calling

main_production_audio_video_call
Sikander Saleem 1 week ago
parent 2f3629b6ef
commit e022aff0b0

@ -21,6 +21,7 @@ class URLs {
static const String chatHubUrlChat = "$chatHubUrl/hubs/chat"; // new V2 apis
static const String resetMessageCount = "$chatHubUrlApi/userChatHistory/AckMessages"; // new V2 apis
static const String unreadMessages = "$chatHubUrlApi/userChatHistory/unread-messages"; // new V2 apis
static const String updateDeviceInfo = "$chatHubUrlApi/user/update-device-info"; // new V2 apis
static const String chatApiKey = "f53a98286f82798d588f67a7f0db19f7aebc839e"; // new V2 apis
static String _host = host1;

@ -358,7 +358,7 @@ class FirebaseNotificationManger {
}
}
initialized(BuildContext context) async {
Future initialized(BuildContext context) async {
// iOS incoming calls: VoIP pushes are handled natively in AppDelegate (PushKit -> CallKit
// via flutter_callkit_incoming). Accept/decline arrive through FlutterCallkitIncoming.onEvent
// (land_page.dart) or, from a cold start, FlutterCallkitIncoming.activeCalls() (splash_page.dart).

@ -45,7 +45,7 @@ class ChatApiClient {
ChatLoginResponse? chatLoginResponse;
Future<ChatLoginResponse?> getChatLoginToken(int moduleId, int requestId, String title, String employeeNumber, String assigneeEmployeeNumber) async {
Future<String> myPlatform() async {
String platform;
if (Platform.isIOS) {
platform = "IOS";
@ -56,6 +56,22 @@ class ChatApiClient {
platform = "HUAWEI";
}
}
return platform;
}
Future<bool> updateDeviceInfo(String employeeNumber) async {
final Map<String, dynamic> payload = {
"employeeNumber": employeeNumber,
"deviceToken": FirebaseNotificationManger.token,
"isHuaweiDevice": (await myPlatform()) == "HUAWEI",
"platform": await myPlatform(),
"voIPToken": FirebaseNotificationManger.voipToken,
};
final Response response = await ApiClient().postJsonForResponse(URLs.updateDeviceInfo, payload, token: chatLoginResponse!.token);
return response.statusCode == 200;
}
Future<ChatLoginResponse?> getChatLoginToken(int moduleId, int requestId, String title, String employeeNumber, String assigneeEmployeeNumber) async {
Response response = await ApiClient().postJsonForResponse(URLs.chatSdkToken, {
"apiKey": URLs.chatApiKey,
"employeeNumber": employeeNumber,
@ -67,8 +83,8 @@ class ChatApiClient {
// "referenceType": "ticket",
"title": title,
"deviceToken": FirebaseNotificationManger.token,
"isHuaweiDevice": platform == "HUAWEI",
"platform": platform,
"isHuaweiDevice": (await myPlatform()) == "HUAWEI",
"platform": await myPlatform(),
"voIPToken": FirebaseNotificationManger.voipToken,
});
@ -109,7 +125,6 @@ class ChatApiClient {
return response.statusCode == 200;
}
Future<List<ChatAttachment>> viewAllDocuments(int moduleId, int referenceId) async {
Response response = await ApiClient().getJsonForResponse("${URLs.chatHubUrlApi}/attachments/conversation?referenceId=$referenceId&moduleCode=$moduleId", token: chatLoginResponse!.token);

@ -20,6 +20,8 @@ import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/models/enums/user_types.dart';
import 'package:test_sa/modules/cx_module/chat/calling/audio_call_page.dart';
import 'package:test_sa/modules/cx_module/chat/calling/video_call_page.dart';
import 'package:test_sa/modules/cx_module/chat/chat_api_client.dart';
import 'package:test_sa/modules/cx_module/chat/chat_provider.dart';
import 'package:test_sa/modules/cx_module/chat/model/chat_participant_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
@ -146,7 +148,11 @@ class _LandPageState extends State<LandPage> {
const MyAssetsPage(fromBottomBar: true),
];
if (isFCM) {
FirebaseNotificationManger().initialized(context);
FirebaseNotificationManger().initialized(context).then((_) {
if (context.settingProvider.isUserFlowMedical) {
ChatApiClient().updateDeviceInfo(context.userProvider.user!.employeeId ?? context.userProvider.user!.username!);
}
});
callingEvents(context);
NotificationManger.initialisation((notificationDetails) {
FirebaseNotificationManger.handleMessage(context, json.decode(notificationDetails.payload!));

Loading…
Cancel
Save