|
|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
@ -287,7 +288,7 @@ Future<void> handleDataMessage(Map<String, dynamic> messageData) async {
|
|
|
|
|
// }
|
|
|
|
|
if (messageData["type"] != null && messageData["type"] == "incoming_call") {
|
|
|
|
|
// if (notificationType == 'incoming_call' || transactionType == 'call') {
|
|
|
|
|
// CRITICAL FIX: Show CallKit UI in foreground just like background
|
|
|
|
|
|
|
|
|
|
final callId = messageData['callId'] as String? ?? messageData['sessionId'] as String? ?? DateTime.now().millisecondsSinceEpoch.toString();
|
|
|
|
|
|
|
|
|
|
final callerId = messageData['callerId'] as String? ?? messageData['callerEmployeeNumber'] as String? ?? messageData['sourceUserId'] as String? ?? 'unknown';
|
|
|
|
|
@ -311,7 +312,7 @@ Future<void> handleDataMessage(Map<String, dynamic> messageData) async {
|
|
|
|
|
|
|
|
|
|
log('📱 [FOREGROUND] Showing CallKit UI...', name: 'FirebaseNotificationManger');
|
|
|
|
|
|
|
|
|
|
// Show CallKit UI using CallKitService
|
|
|
|
|
Timer? _callTimeoutTimer;
|
|
|
|
|
try {
|
|
|
|
|
final callKitParams = CallKitParams(
|
|
|
|
|
id: callId,
|
|
|
|
|
@ -372,15 +373,21 @@ Future<void> handleDataMessage(Map<String, dynamic> messageData) async {
|
|
|
|
|
// "rationaleMessagePermission": "Notification permission is required, to show notification.",
|
|
|
|
|
// "postNotificationMessageRequired": "Notification permission is required, Please allow notification permission from setting."
|
|
|
|
|
// });
|
|
|
|
|
// Check if can use full screen intent
|
|
|
|
|
await FlutterCallkitIncoming.canUseFullScreenIntent();
|
|
|
|
|
|
|
|
|
|
// Request full intent permission
|
|
|
|
|
await FlutterCallkitIncoming.canUseFullScreenIntent();
|
|
|
|
|
await FlutterCallkitIncoming.requestFullIntentPermission();
|
|
|
|
|
FlutterCallkitIncoming.unsilenceEvents();
|
|
|
|
|
FlutterCallkitIncoming.showCallkitIncoming(callKitParams);
|
|
|
|
|
log('✅ [FOREGROUND] CallKit UI displayed successfully', name: 'FirebaseNotificationManger');
|
|
|
|
|
_callTimeoutTimer?.cancel();
|
|
|
|
|
_callTimeoutTimer = Timer(const Duration(seconds: 30), () async {
|
|
|
|
|
await FlutterCallkitIncoming.endCall(callId);
|
|
|
|
|
await FlutterCallkitIncoming.endAllCalls();
|
|
|
|
|
_callTimeoutTimer?.cancel();
|
|
|
|
|
_callTimeoutTimer = null;
|
|
|
|
|
});
|
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
|
log('❌ [FOREGROUND] Failed to show CallKit UI: $e\nStack: $stackTrace', name: 'FirebaseNotificationManger');
|
|
|
|
|
_callTimeoutTimer?.cancel();
|
|
|
|
|
_callTimeoutTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|