Show incoming call notification when the app is terminated in flutter app

I’m using Agora to implement a video call in my application, and I’m using this flutter_callkit_incoming to show incoming calls to the user.

My flow is: when a call comes, it gets a notification from FCM and shows the Flutter incoming call kit notification. The flow works absolutely fine when the app is in the foreground and in the background (not terminated from the app switcher).

When the app is terminated, FCM sends the notification for the call, but it is unable to trigger the call kit to initiate the incoming call. I need to trigger the call kit when the app is terminated.

Is there any way to do it?

Has anyone faced similar issues and solved them?

heres the FCM background Handler
This works absolutely fine when the app is in the background but not terminated, but it can’t trigger the CallKit when the app is terminated.

@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
    await Firebase.initializeApp();
  

  String docName = '';
  String docImage = '';
  Uuid uuid = const Uuid();

  dev.log('Message !also contained a notification: ${message.notification}');

  if (message.data['type'] == 'call') {
    PermissionRequestHandler.requestCameraAndMicPermissionsForCalling();
    docName = message.data['doc_name'];
    docImage = message.data['doc_image'];

    logger.d('docName: $docName');
    logger.d('docImage: $docImage');

    showCallkitIncoming(docName, docImage, uuid.v4());
  } 
 }

the function to trigger the callkit

Future<void> showCallkitIncoming(
    String docName, String docImage, String uuid) async {
    final params = CallKitParams(
        id: uuid,
        nameCaller: docName,
        appName: 'AppName',
        avatar: docImage,
        type: 0,
        textAccept: 'Accept',
        textDecline: 'Decline',
        duration: 30000,
        missedCallNotification: const NotificationParams(isShowCallback: false),
        android: const AndroidParams(
          backgroundColor: '#2E2727',
          isCustomNotification: true,
          isShowLogo: false,
          isShowFullLockedScreen: true,
          ringtonePath: 'system_ringtone_default',
        ),
        ios: const IOSParams(
          iconName: 'Getfit',
          supportsVideo: false,
          audioSessionMode: 'default',
          audioSessionActive: true,
          audioSessionPreferredSampleRate: 44100.0,
          audioSessionPreferredIOBufferDuration: 0.005,
          supportsDTMF: true,
          supportsHolding: false,
          supportsGrouping: false,
          supportsUngrouping: false,
          ringtonePath: 'system_ringtone_default',
        ));

    await FlutterCallkitIncoming.showCallkitIncoming(params);
}

this is the error log when app is terminated and a call notification arrived from FCM. It didn’t trigger the callkit incoming call notification rather logging this

I/flutter (21552): FlutterFire Messaging: An error occurred in your background messaging handler:
I/flutter (21552): PlatformException(java.lang.Exception: Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly., Exception, Cause: null, Stacktrace: java.lang.Exception: Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
I/flutter (21552):      at io.flutter.plugins.firebase.core.i.v(Unknown Source:12)
I/flutter (21552):      at io.flutter.plugins.firebase.core.i.l(Unknown Source:0)
I/flutter (21552):      at io.flutter.plugins.firebase.core.b.run(Unknown Source:4)
I/flutter (21552):      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
I/flutter (21552):      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
I/flutter (21552):      at java.lang.Thread.run(Thread.java:1012)
I/flutter (21552): , null)

New contributor

Mujahedul Islam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật