createCallNotification static method

dynamic createCallNotification(
  1. String title,
  2. String messageContent
)

Implementation

static createCallNotification(String title, String messageContent) async {
  unReadCallCount += 1;
  unReadCallCount += await getTotalUnReadCount();
  var channel = buildCallNotificationChannel();
  var androidNotificationDetails = AndroidNotificationDetails(
    channel.id,
    channel.name,
    channelDescription: channel.description,
    importance: Importance.max,
    autoCancel: true,
    icon: 'ic_notification',
    color: buttonBgColor,
    number: unReadCallCount,
    category: AndroidNotificationCategory.missedCall,
  );
  final String? notificationUri = SessionManagement.getNotificationUri();
  var iosNotificationDetail = DarwinNotificationDetails(
      categoryIdentifier: darwinNotificationCategoryPlain,
      sound: notificationUri,
      presentBadge: true,
      presentSound: true,
      presentAlert: true);

  var notificationDetails = NotificationDetails(
      android: androidNotificationDetails, iOS: iosNotificationDetail);
  await flutterLocalNotificationsPlugin
      .resolvePlatformSpecificImplementation<
          AndroidFlutterLocalNotificationsPlugin>()
      ?.createNotificationChannel(channel);

  await flutterLocalNotificationsPlugin.show(Constants.callNotificationId,
      title, messageContent, notificationDetails,
      payload: "${Constants.callNotificationId}");
}