|
|
|
|
@ -259,25 +259,33 @@ class _SplashPageState extends State<SplashPage> {
|
|
|
|
|
final extra = lastCall.extra ?? {};
|
|
|
|
|
final isVideoCall = extra["isVideoCall"] == true || extra["isVideoCall"]?.toString().toLowerCase() == 'true';
|
|
|
|
|
|
|
|
|
|
// Asks for mic (+camera) on Accept; offers Settings if permanently denied.
|
|
|
|
|
if (!await ensureCallPermissionsOnAccept(context, isVideoCall: isVideoCall)) {
|
|
|
|
|
await FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
await notifyCallerDeclined(extra, reason: 'PERMISSION_DENIED');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// The same accepted call may also arrive via land_page's callkit listener - open it once.
|
|
|
|
|
if (!FirebaseNotificationManger.beginAcceptedCall(extra["callId"]?.toString() ?? callUuid ?? '')) return;
|
|
|
|
|
try {
|
|
|
|
|
// Asks for mic (+camera) on Accept; offers Settings if permanently denied.
|
|
|
|
|
if (!await ensureCallPermissionsOnAccept(context, isVideoCall: isVideoCall)) {
|
|
|
|
|
await FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
await notifyCallerDeclined(extra, reason: 'PERMISSION_DENIED');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await FlutterCallkitIncoming.setCallConnected(callUuid!);
|
|
|
|
|
final sender = Participants(employeeNumber: extra["calleeEmployeeNumber"]?.toString());
|
|
|
|
|
final recipient = Participants(employeeNumber: extra["callerEmployeeNumber"]?.toString());
|
|
|
|
|
final moduleId = int.tryParse(extra["moduleId"]?.toString() ?? '') ?? 0;
|
|
|
|
|
final referenceID = int.tryParse(extra["referenceId"]?.toString() ?? '');
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
await Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => isVideoCall
|
|
|
|
|
? VideoCallPage(sender: sender, recipient: recipient, moduleId: moduleId, referenceID: referenceID, isAccept: true)
|
|
|
|
|
: AudioCallPage(sender: sender, recipient: recipient, moduleId: moduleId, referenceID: referenceID, isAccept: true)));
|
|
|
|
|
FlutterCallkitIncoming.endCall(lastCall.extra?["callId"]);
|
|
|
|
|
FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
// iOS: never call setCallConnected on an already-answered call - it issues another
|
|
|
|
|
// CXAnswerCallAction, which re-emits ACTION_CALL_ACCEPT and re-opens the call page.
|
|
|
|
|
if (!Platform.isIOS) await FlutterCallkitIncoming.setCallConnected(callUuid!);
|
|
|
|
|
final sender = Participants(employeeNumber: extra["calleeEmployeeNumber"]?.toString());
|
|
|
|
|
final recipient = Participants(employeeNumber: extra["callerEmployeeNumber"]?.toString());
|
|
|
|
|
final moduleId = int.tryParse(extra["moduleId"]?.toString() ?? '') ?? 0;
|
|
|
|
|
final referenceID = int.tryParse(extra["referenceId"]?.toString() ?? '');
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
await Navigator.of(context).push(MaterialPageRoute(
|
|
|
|
|
builder: (_) => isVideoCall
|
|
|
|
|
? VideoCallPage(sender: sender, recipient: recipient, moduleId: moduleId, referenceID: referenceID, isAccept: true)
|
|
|
|
|
: AudioCallPage(sender: sender, recipient: recipient, moduleId: moduleId, referenceID: referenceID, isAccept: true)));
|
|
|
|
|
FlutterCallkitIncoming.endCall(lastCall.extra?["callId"]);
|
|
|
|
|
FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
} finally {
|
|
|
|
|
FirebaseNotificationManger.endAcceptedCall();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
await FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
|