showNotification method

Future<void> showNotification({
  1. required dynamic message,
  2. required FlutterLocalNotificationsPlugin fln,
  3. bool data = false,
})

Implementation

Future<void> showNotification( { required /*RemoteMessage*/ message, required FlutterLocalNotificationsPlugin fln, bool data=false}) async {
  try{
    MessageNotification notify = MessageNotification();
    if(data) {
      notify = MessageNotification.fromJson(message.data);
    }else{
      notify = MessageNotification.parseNotification(message.notification);
    }
    logCat('title: ${notify.title} / body:${notify.body} / image:${notify.image} / payload:${notify.payload}');

    if(notify.image!='' && notify.image.isNotEmpty) {
      try{
        await showBigPictureNotificationHiddenLargeIcon(title: notify.title, body: notify.body, payload: notify.payload, imagePath: notify.image, flutterLocalNotificationsPlugin: fln);
      }catch(e) {
        await showBigTextNotification(title: notify.title, body: notify.body, payload: notify.payload, flutterLocalNotificationsPlugin: fln);
      }
    }else {
      await showBigTextNotification(title: notify.title, body: notify.body, payload: notify.payload, flutterLocalNotificationsPlugin: fln);
    }
  }catch(ex, trace){
    logError(ex, trace: trace, position: 'showNotification');
  }
}