activateNotification method

Future<void> activateNotification({
  1. required String time,
  2. required int notificationId,
  3. required String codeLecture,
  4. String? codeSubscription,
  5. required String titre,
  6. required String description,
  7. String imageBg = '${Constant.assetsBiblePath}b1.jpg',
  8. required String pageUrl,
  9. ChannelModel? channel,
})

Implementation

Future<void> activateNotification({
  required String time,
  required int notificationId,
  required String codeLecture, String? codeSubscription,
  required String titre,
  required String description,
  String imageBg='${Constant.assetsBiblePath}b1.jpg',
  required String pageUrl,
  ChannelModel? channel,
}) async
{
  try{
    _timeReminderReadPlan = time;
    PayLoadModel payLoad = PayLoadModel();
    payLoad.notificationId = notificationId;
    payLoad.codePage = codeLecture;
    payLoad.pageUrl = pageUrl;
    payLoad.titre = titre;
    payLoad.description = description;
    payLoad.imageBg = imageBg;
    ChannelModel chan = channel??ChannelModel();

    await flutterLocalNotificationsPlugin.zonedSchedule(
        payLoad.notificationId,
        'msg_do_not_forget_to_read_bible_plan'.tr,// (${'label_stay_on_track'.tr})',
        ' [ ${payLoad.titre} ]',// ${payLoad.description.toLowerCase()}',

        payload: payLoad.jsonEncodeString,
        _nextInstanceOfTenAM(),
        NotificationDetails(
            android: AndroidNotificationDetails(
              chan.id,
              chan.name,
              channelDescription: chan.description,
              // actions: <AndroidNotificationAction>[
              //   AndroidNotificationAction('id_1', 'Action 1'),
              //   AndroidNotificationAction('id_2', 'Action 2'),
              //   AndroidNotificationAction('id_3', 'Action 3'),
              // ],
            ),
            iOS: DarwinNotificationDetails()
        ),
        androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
        matchDateTimeComponents: DateTimeComponents.time);

  }catch(ex, trace){
    logError(ex, trace: trace, position: 'ERROR:Utilities.Exception: activateNotification()');
  }
}