locked
Repeating toast occurence RRS feed

  • Question

  • Hi, I want to know how to create a repeating toast. The idea is same with Alarm on Windows 10 and Windows Phone, user could choose which method of occurrence they want. I created on time and once alarm, not repeating time.

    This is my CodeClass.cs

    public class ToastShow
    {
        private Random random = new Random((int)DateTime.Now.Ticks);
    
        public void Add(ref ListBox display, string value, string value2, TimeSpan occurs)
        {
            DateTime when = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                occurs.Hours, occurs.Minutes, occurs.Seconds);
    
            if (when > DateTime.Now)
            {
               //toast
            }
        }
    }

    This is the method how to send input to toast

    private void ButtonSendToast_Click(object sender, RoutedEventArgs e)
            {
                toastShow.Add(ref Display, Title.Text, Description.Text, Time1.Time);            
            }

    I still not creating choice for repeating toast, assume it will be a check box, when user choose daily reminder or no. Or user could insert more than one time for one toast. Thanks for your help before.

    Saturday, November 26, 2016 7:32 AM

Answers

  • Hello Olivia Olga,

    For repeating toast like Alarm app, you can use ScheduledToastNotification class combined with backgroundtask and the timer trigger. The ScheduledToastNotification  has restricted MaximumSnoozeCount  to 5 as the max repeat times. But we can create new ScheduledToastNotification once we need more.

    Here is a basic sample about ScheduledToastNotification  http://stackoverflow.com/questions/32899713/timetrigger-scheduler-in-windows-10-uwp-for-less-than-15-minutes. You can also find sample from the official page.

    Best  regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by andrewbares7 Tuesday, December 6, 2016 9:14 PM
    • Marked as answer by Olivia Olga Friday, December 9, 2016 4:12 AM
    Monday, November 28, 2016 11:29 AM

All replies

  • I would create two different addToast functions and then just use them, depending on whether the user wants to be notified one time or multiple times.
    Saturday, November 26, 2016 2:17 PM
  • Hello Olivia Olga,

    For repeating toast like Alarm app, you can use ScheduledToastNotification class combined with backgroundtask and the timer trigger. The ScheduledToastNotification  has restricted MaximumSnoozeCount  to 5 as the max repeat times. But we can create new ScheduledToastNotification once we need more.

    Here is a basic sample about ScheduledToastNotification  http://stackoverflow.com/questions/32899713/timetrigger-scheduler-in-windows-10-uwp-for-less-than-15-minutes. You can also find sample from the official page.

    Best  regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by andrewbares7 Tuesday, December 6, 2016 9:14 PM
    • Marked as answer by Olivia Olga Friday, December 9, 2016 4:12 AM
    Monday, November 28, 2016 11:29 AM
  • Great answer Barry! Additionally, here's a Quickstart on sending alarms in Windows 10. Essentially your code can just schedule the same alarm multiple times, each one minute apart, if you'd like. The quickstart doesn't describe that, but you should be able to figure it out :)
    • Proposed as answer by Barry Wang Wednesday, December 7, 2016 1:37 AM
    Tuesday, December 6, 2016 9:16 PM
  • Thanks Barry, I saw that thread.

    What I want is I want to create a toast that could repeat in a next day every day, for example when drink a medicine, user want computer or mobile remind him/her to drink their medicine 3 times every day until some time. I try to figure what algorithm should I do.

    Friday, December 9, 2016 4:12 AM
  • Friday, December 9, 2016 4:15 AM