setForegroundNotification method

Future<void> setForegroundNotification({
  1. IOSNotificationForegroundSetting iOSsetting = const IOSNotificationForegroundSetting(),
  2. required AndroidNotificationForegroundSetting androidSetting,
})

Implementation

Future<void> setForegroundNotification(
    {IOSNotificationForegroundSetting iOSsetting = const IOSNotificationForegroundSetting(),
    required AndroidNotificationForegroundSetting androidSetting}) async {
  if (Platform.isIOS) {
    _fcmInterface.setForegroundNotificationPresentationOptions(
      alert: iOSsetting.alert,
      badge: iOSsetting.badge,
      sound: iOSsetting.sound,
    );
  } else if (Platform.isAndroid) {
    _androidForegroundSetting = androidSetting;
    _flutterLocalNotifications.initialize(
      InitializationSettings(
        android: AndroidInitializationSettings(androidSetting.icon),
      ),
      onDidReceiveNotificationResponse: _onTapNotificationLocalNotification,
    );
    _flutterLocalNotifications
        .resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>()
        ?.requestNotificationsPermission();
  }
}