Scheduled Toast Notification Expiration RRS feed

  • Question

  • Hi,

    I am trying to do have an effect similar to the expiration of a toast notification in the scheduled toast notification.

    What I'm trying to do is to schedule 10 notifications at specific times as reminder so they would appear to the user with a custom audio (longer than 15 seconds). I need the audio to play for each reminder. If the user miss a reminder it wouldn't matter he should only see the latest reminder shown.

    Using the expiration property setting the timeout to 1 second before the next reminder would do the trick. With scheduled toast notifications since the expiration property isn't available I tried to add a new toast using the same group & tag and having the SuppressPopup property set to true. That didn't work since this ghost toast popup won't appear unless the user interact with the real one. Is there another way to do this without the expiration property?

    BTW, I don't get the utility of having the timeout functionality in a normal toast since first I don't see a reason the user would want to receive a notification in the notification center while the application is running. And second, the developer should be able to remove the notification from the notification center at will by using the ToastNotificationHistory class.

    Another related question, also since the expiration time isn't available, I need the toast notification to play the sound only on the time it was scheduled to show (or within a specified time) if it's later than that it either show a silent or ghost notification or not show it at all. Again with an expiration time that would work by setting the expiration time to what is needed and either adding another ghost notification after that or just not adding anything. Since there is no expiration time for scheduled notifications if the user shutdown the machine before a schedule and turn it back on 30 minutes after the scheduled time the notification would appear and the audio will play as if this was the scheduled time. A solution for this would be to add a background task triggered by user login that would delete old notifications. But I'm not sure what would start first. Would the notifications appear and then the background tasks or would the background tasks be given priority?


    Wednesday, November 29, 2017 5:23 AM

All replies

  • Hey Khaled! We're actually adding the expiration time property to ScheduledToastNotification in the next release of Windows 10! So in the future you'll be able to utilize it just like you can on the normal ToastNotification.

    But in the meantime, for your scenario, you should be able to simply set the same tag/group on the notifications, and then the newer ones will simply replace the current ones.

    You said you tried this, but you set SuppressPopup to true for some reason? You shouldn't do this, since it sounds like you want it to pop up (and play the audio).

    You mentioned being able to remove the notification by using ToastNotificationHistory. You can do that too, for both scheduled and normal toasts. Note that if the notification hasn't appeared yet, you have to use the RemoveFromSchedule methods just like how you add to the schedule. But then once the toast has appeared, you remove it from the History.

    For your final question... If the machine is turned off and misses the scheduled interval by more than 5 minutes, the scheduled notification will be dropped. So if it was scheduled to go off at 9:30 PM, but the user doesn't turn their machine on till 9:45 PM, then it'll be dropped. But if they turned the machine on at 9:34 PM, it'll appear. As for using a background task to run before this happens, it's very unlikely the background task would execute before the notification gets delivered.

    • Proposed as answer by andrewbares7 Thursday, November 30, 2017 12:48 AM
    Thursday, November 30, 2017 12:48 AM