The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Default/Maximum ExpirationTime for ToastNotification RRS feed

  • Question

  • Hello,

    I've a (hopefully short and easy) question regarding ToastNotification.ExpirationTime. The documentation is lacking one important piece of information:

    What is the maximum and default value for the expiration time of a toast notification?

    Within my app Action Note, I'm using these notifications in a "persistent" fashion, where the Action Center is used for note taking. Unfortunately, I experienced the following:

    1. When the value is null (default), then the notification is removed after exactly 72 hours.
    2. When i tried to use a specified value (for testing purposes, I used "DateTimeOffset.Now.AddDays(31)"; hence 1 month), one notification was auto-removed after about 3 days as well, another one seemed to be persistent for 4-5 days. I'm note sure if this was just coincidence...

    Thank you for your help!

    Best regards,
    Benjamin

    Wednesday, January 20, 2016 5:09 PM

Answers

  • Hey Benjamin, thanks for reporting this!

    The max expiration time (and the default) on toasts is 3 days. We're considering removing the max cap in the future, but right now you'll always be limited to at most 3 days.

    Workaround...
    Use a series of scheduled toasts in order to get a toast to stay in Action Center for a month. Schedule them 2.9 days apart, and assign the same Tag on each ScheduledToastNotification so that the new one replaces the old one. Set SuppressPopup to false on the scheduled toasts so that when the scheduled toasts appear, they don't pop a toast banner interrupting the user.

    • Proposed as answer by andrewbares7 Tuesday, January 26, 2016 6:45 PM
    • Marked as answer by Xavier Xie-MSFT Tuesday, February 2, 2016 3:21 AM
    Tuesday, January 26, 2016 6:45 PM

All replies

  • Hi Benjamin Sautermeister,

    Based on my researching, I didn’t find related information. I would consult it internally and if I could get any useful information, I would tell you in time.

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 21, 2016 10:37 AM
  • Sounds good.

    I'm looking forward to your further investigations...

    Monday, January 25, 2016 5:32 PM
  • Hey Benjamin, thanks for reporting this!

    The max expiration time (and the default) on toasts is 3 days. We're considering removing the max cap in the future, but right now you'll always be limited to at most 3 days.

    Workaround...
    Use a series of scheduled toasts in order to get a toast to stay in Action Center for a month. Schedule them 2.9 days apart, and assign the same Tag on each ScheduledToastNotification so that the new one replaces the old one. Set SuppressPopup to false on the scheduled toasts so that when the scheduled toasts appear, they don't pop a toast banner interrupting the user.

    • Proposed as answer by andrewbares7 Tuesday, January 26, 2016 6:45 PM
    • Marked as answer by Xavier Xie-MSFT Tuesday, February 2, 2016 3:21 AM
    Tuesday, January 26, 2016 6:45 PM
  • Thank you for your answer. I really hope the max. expiration limit will be increased (or even complete removed) in the near future.

    Regarding your workaround:
    Unfortunately, there is a bug (on Windows PC with TH2 update only!) regarding SuppressPopup (see my MSDN posts here). Thus, we can not simply replace the the toast messages, but we have to remove all of them and re-add them afterwards. The only drawback here is that the "Action Center" icon is show in the StatusTray. Hence, the user might think he got a new notification, even when an existing one was just updated.

    But I will give it a try...

    Wednesday, January 27, 2016 12:20 PM
  • Ah darn, I forgot about that SuppressPopup bug. But now that I'm thinking about ExpirationTime, I think I might have developed a workaround for this entire situation...

    Have the original toast expire at exactly the same time that the scheduled toast is set to appear!

    The code below demos this for replacing the original toast with a scheduled toast after 15 seconds. Theoretically, you should be able to do this with the timespan of 2.9 days, and add numerous scheduled toasts each expiring and appearing subsequently in order to reach a longer timespan.

    DateTimeOffset switchTime = DateTimeOffset.Now.AddSeconds(15);
    
    ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(doc)
    {
        Tag = "1",
        ExpirationTime = switchTime
    });
    
    
    ToastNotificationManager.CreateToastNotifier().AddToSchedule(new ScheduledToastNotification(docUpdated, switchTime)
    {
        Tag = "1",
        SuppressPopup = true
    });

    But simply removing and re-adding them might be easier. In either case, the Action Center icon will be illuminated regardless.

    Wednesday, January 27, 2016 5:31 PM