setPeriodicPush method
- PushEntity push
Set periodic local push with interval from PushEntity.repeatInterval
Implementation
@override
Future<void> setPeriodicPush(PushEntity push) async {
final repeatInterval = push.repeatInterval;
if (repeatInterval == null) {
_logger.error(
'Failed to set periodic push, repeat interval is null',
error: RepeatIntervalNullException(),
stackTrace: StackTrace.current,
);
return;
}
final title = push.title;
_logger.info('Scheduling periodic push $title');
final id = push.pushId;
await _localNotifications.cancel(id);
await _localNotifications.periodicallyShow(
id,
title,
push.body,
switch (repeatInterval) {
PushRepeatInterval.everyMinute => RepeatInterval.everyMinute,
PushRepeatInterval.hourly => RepeatInterval.hourly,
PushRepeatInterval.daily => RepeatInterval.daily,
PushRepeatInterval.weekly => RepeatInterval.weekly,
},
PeriodicPushConfig._notificationDetails,
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
);
}