public MarkAsCompletedTask(TaskReminderNotification notification) { _logger = Mvx.IoCProvider.Resolve <ILogger>().ForContext <MarkAsCompletedTask>(); _telemetryService = Mvx.IoCProvider.Resolve <ITelemetryService>(); _dataService = Mvx.IoCProvider.Resolve <IMiraiNotesDataService>(); _notificationService = Mvx.IoCProvider.Resolve <IAndroidNotificationService>(); _textProvider = Mvx.IoCProvider.Resolve <ITextProvider>(); _messenger = Mvx.IoCProvider.Resolve <IMvxMessenger>(); _notification = notification; }
public void ShowTaskReminderNotification(TaskReminderNotification notification) { //we create the pending intent when the user clicks the notification... var action = new NotificationAction { Action = NotificationActionType.OPEN_TASK, TaskId = notification.TaskId, TaskListId = notification.TaskListId }; var clickIntent = MainActivity.CreateIntent( notification.Id, MainActivity.InitParamsKey, JsonConvert.SerializeObject(action)); var pendingIntent = TaskStackBuilder.Create(Application.Context) .AddNextIntent(clickIntent) .GetPendingIntent(1, (int)PendingIntentFlags.UpdateCurrent); var localNotification = new TaskNotification { LargeContent = $"{notification.TaskTitle}{System.Environment.NewLine}" + $"{notification.TaskBody}", Title = notification.TaskListTitle, Id = notification.Id }; var builder = BuildSimpleNotification(localNotification); builder.SetContentIntent(pendingIntent); //we create the pending intent when the user clicks the mark as completed button... var mcIntent = MarkTaskAsCompletedReceiver.CreateIntent( notification.Id, MarkTaskAsCompletedReceiver.MarkTaskAsCompletedKey, JsonConvert.SerializeObject(notification)); var mcPendingIntent = PendingIntent.GetBroadcast( Application.Context, 0, mcIntent, 0); string title = _textProvider.Get("MarkTaskAs", _textProvider.Get("Completed")); builder.AddAction(Resource.Drawable.ic_check_white_48dp, title, mcPendingIntent); var notif = builder.Build(); NotifManager.Notify(notification.Id, notif); }
public void ScheduleNotification(TaskReminderNotification notification) { var content = GenerateTaskReminderToastContent( notification.TaskListId, notification.TaskId, notification.TaskListTitle, notification.TaskTitle, notification.TaskBody); var toastNotification = new ScheduledToastNotification(content.GetXml(), notification.DeliveryOn) { Id = $"{notification.Id}", Tag = TaskReminderToastTag }; ScheduleToastNotification(toastNotification); }
public void AddNewNotificationForTask(PlanTaskDto taskDto) { if (taskDto.RemindAt.HasValue) { var notitification = new TaskReminderNotification(_config); notitification.TaskPlannedDate = taskDto.PlannedBeginDate.HasValue ? taskDto.PlannedBeginDate.ToUtc().ToString() : "-"; notitification.TaskTitle = taskDto.Title; var entity = notitification.GetNotificationEntity(); entity.SendingDate = taskDto.RemindAt.Value.ToUniversalTime(); entity.State = DAL.enums.EmailStateEnum.NotSent; entity.ReceiverEmail = taskDto.Creator.Email; _context.Notifications.Add(entity); _context.SaveChanges(); } }
public void ScheduleNotification(TaskReminderNotification notification) { var now = DateTimeOffset.Now; bool showNow = notification.DeliveryOn <= now; if (showNow) { ShowTaskReminderNotification(notification); return; } var intent = NotificationSchedulerReceiver.CreateIntent( notification.Id, NotificationSchedulerReceiver.TaskReminderNotificationKey, JsonConvert.SerializeObject(notification)); var pendingIntent = PendingIntent.GetBroadcast( Application.Context, 0, intent, PendingIntentFlags.CancelCurrent); var future = (long)(notification.DeliveryOn - now).TotalMilliseconds; var milis = Java.Lang.JavaSystem.CurrentTimeMillis() + future; var alarmManager = GetAlarmManager(); if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { alarmManager.SetExactAndAllowWhileIdle(AlarmType.RtcWakeup, milis, pendingIntent); } else if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat) { alarmManager.SetExact(AlarmType.RtcWakeup, milis, pendingIntent); } else { alarmManager.Set(AlarmType.RtcWakeup, milis, pendingIntent); } }
public NotificationSchedulerTask(TaskReminderNotification notification) : this() { _reminderNotification = notification; }