improvements

main_production_audio_video_call
Sikander Saleem 7 days ago
parent f222c589a9
commit f9274e070e

@ -35,10 +35,28 @@ Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
}
@pragma('vm:entry-point')
Future<void> onBackgroundMessage(CallEvent event) async {
Future<void> onBackgroundMessage(CallEvent event1) async {
// This executes when a background/killed action happens
switch (event.eventName) {
FlutterCallkitIncoming.onEvent.listen((CallEvent? event) {
switch (event!.eventName) {
case CallEventConstants.actionCallAccept:
// Handle logic when user hits Accept while app transitions to foreground
// var extraData = event?.body['extra'];
// Navigate to Call Screen
print("onBackgroundMessage:actionCallAccept:${event}");
break;
case CallEventConstants.actionCallDecline:
// Notify backend that user declined
print("onBackgroundMessage:actionCallDecline:${event}");
break;
default:
break;
}
});
switch (event1.eventName) {
case CallEventConstants.actionCallAccept:
"actionCallAccept".showToast;
break;

@ -161,7 +161,6 @@ void main() async {
if (Platform.isAndroid) {
FlutterCallkitIncoming.onBackgroundMessage(onBackgroundMessage);
}
FlutterCallkitIncoming.endAllCalls();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
// HttpOverrides.global = MyHttpOverrides(); // for later use.
_configureLocalTimeZone();

@ -6,6 +6,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_callkit_incoming/entities/call_kit_params.dart';
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
@ -16,6 +17,8 @@ import 'package:test_sa/controllers/notification/firebase_notification_manger.da
import 'package:test_sa/controllers/providers/api/user_provider.dart';
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/cx_module/chat/calling/audio_call_page.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_lazy_loading.dart';
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
@ -238,27 +241,27 @@ class _SplashPageState extends State<SplashPage> {
);
}
checkVoipCalling() async {
Future checkVoipCalling() async {
var activeCalls = await FlutterCallkitIncoming.activeCalls();
if (activeCalls is List && activeCalls.isNotEmpty) {
final lastCall = activeCalls.last;
CallKitParams lastCall = activeCalls.last;
if (lastCall.isAccepted) {
final String? callerId = lastCall.extra?['callerId'];
final String? callUuid = lastCall.id;
print("lastCall:$lastCall");
// // Check if the last state recorded was an accepted call
// if (lastCall['isAccepted'] == true) {
// final String? callerId = lastCall['extra']['callerId'];
// final String? callUuid = lastCall['id'];
//
// await FlutterCallkitIncoming.setCallConnected(callUuid!);
//
// // Route user to the calling interface
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => InAppCallScreen(callerId: callerId)),
// );
// }
await FlutterCallkitIncoming.setCallConnected(callUuid!);
await Navigator.of(context).push(MaterialPageRoute(
builder: (_) => AudioCallPage(
sender: Participants(employeeNumber: lastCall.extra?["calleeEmployeeNumber"]),
recipient: Participants(employeeNumber: lastCall.extra?["callerEmployeeNumber"]),
moduleId: int.parse(lastCall.extra!["moduleId"]),
isAccept: true)));
FlutterCallkitIncoming.endCall(lastCall.extra?["callId"]);
FlutterCallkitIncoming.endAllCalls();
}
} else {
await FlutterCallkitIncoming.endAllCalls();
}
}

Loading…
Cancel
Save