Action Center in the Cloud – Universal Dismiss


New in Anniversary Update (coming soon to Insider builds): Action Center in the Cloud and Universal Dismiss means that when you dismiss a notification from one device, the same notification on your other devices is also dismissed.

The common example of this scenario is calendar reminders… you have a calendar app on both of your devices… you get a reminder on your phone and desktop… you click dismiss on your desktop… thanks to Universal Dismiss, the reminder on your phone is also dismissed! Enabling Universal Dismiss only requires one line of code!

In this scenario, the key fact is that the same app is installed on multiple devices, meaning that each device is already receiving notifications. The Calendar app is the iconic example, since Outlook Calendar is installed on both your Windows PC and your phone, and each instance of the app already sends you separate reminders on each device. By adding support for Universal Dismiss, those separate instances of the same reminders can be linked across devices.

How to enable Universal Dismiss

As a developer, enabling Universal Dismiss is extremely easy. You simply need to provide an ID that allows us to link each notification across devices, so that when the user dismisses a notification from one device, the corresponding linked notification is dismissed from the other device.

RemoteId: An identifier that uniquely identifies a notification across devices.

It only takes one line of code to add RemoteId, enabling support for Universal Dismiss! How you generate your RemoteId is up to you – however, you need to make sure that it uniquely identifies your notification across devices, and that the same identifier can be generated from different instances of your app running on different devices.

For example, in my homework planner app, Power Planner, I generate my RemoteId by saying that it is of type “reminder”, and then I include the online account ID and the online identifier of the homework item. I can consistently generate the exact same RemoteId, regardless of which device is sending the notification, since these online ID’s are shared across the devices.

// Using the NuGet package Microsoft.Toolkit.Uwp.Notifications
ToastContent content = new ToastContent()
{
    // ... omitted
};
 
var toast = new ScheduledToastNotification(content.GetXml(), startTime);

// If the RemoteId property is present
if (ApiInformation.IsPropertyPresent(typeof(ScheduledToastNotification).FullName, nameof(ScheduledToastNotification.RemoteId)))
{
    // Assign the RemoteId to add support for Universal Dismiss
    toast.RemoteId = $"reminder_{account.AccountId}_{homework.Identifier}"
}
 
ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);

The following code runs on both my phone and desktop app, meaning that the notification on both devices will have the same RemoteId.

That’s all you have to do! When the user dismisses (or clicks on) a notification, we’ll check if it has a RemoteId, and if so, we’ll fan out a dismiss of that RemoteId across all the user’s devices.

Known Issue: Retrieving the RemoteId via the ToastNotificationHistory.GetHistory() API’s will always return empty string rather than the RemoteId you specified. Don’t worry, everything is functional – it’s only retrieving the value that’s broken.

Note: If the user disables notification uploading for your app (or completely disables notification uploading), then this feature will not work, since we do not have your notifications in the cloud.

What if the app is installed on both devices?

If the user already has your app on their PC, we will automatically mute the mirrored phone notification so that you don’t see duplicate notifications. Mirrored notifications will be auto-muted based on the following criteria…

  1. An app on the PC exists with either the same display name or the same PFN (Package Family Name)
  2. That PC app has sent a toast notification (if the app hasn’t toasted yet, we’ll still show the phone notifications, since chances are, you haven’t actually launched the PC app yet)
Comments (5)

  1. This is great idea, however I have few notes:
    1. What is syntax for xml payload? (I’m not using Notifications NuGet package)
    2. I created Event in calendar on my phone, notification appeared on phone and PC, I dismissed it on phone, but it remained not dismissed on PC. Is it supposed to work for Outlook Calendar app? Also tried vice versa scenario – dismissed on PC first, but it didn’t dismiss on my phone (My PC is 14393.103 and phone is 14905.1000).
    3. Why only dismiss is broadcasted? If I understand it right, this Universal Dismiss mechanism is targeting the case when user has same app on multiple devices. That excludes Toasts mirroring mechanism, which is targeting the case when user has app only on 1 device. However, mirroring is capable of broadcasting whole TriggerDetails result, which e.g. may include snoozing information. But when user has app on both devices, Snoozing information is not broadcasted, since only Universal Dismiss can be applied in such scenario, am I right?

    Thanks!

    1. andrewbares7 says:

      Hey Viktor!

      1) There’s nothing in the XML payload. It’s a new property on the ToastNotification object (and ScheduledToastNotification), called RemoteId.

      2) Nope, Calendar hasn’t implemented it in their app yet :/ difficulty there is getting a shared identifier for the calendar event, since Exchange doesn’t provide any common shared identifier for calendar appointments.

      3) We thought about enabling broadcasting the snooze… but there’s additional complications around that. For example, what about a quick reply toast notification? You don’t want to broadcast the “send” press to all the devices, otherwise the same message would be sent multiple times… So we would have to add a property on your button, like “hint-broadcastAction”, or something, and you would have to opt-into the broadcast. But we didn’t have time to build that. So for now, if you click Snooze on your PC, the notification will be dismissed on your phone, and it will NOT re-appear later. Trust me, I’m not a fan of that behavior! But time is always limited unfortunately. And it’s only things like snoozing reminders that are affected, it works perfectly fine for other things like messaging apps.

      1. Hey Andrew, thanks for response.
        1. Sorry, my bad, I didn’t read the code carefully.
        2. Is there any other app I could test it?
        3. I see. I don’t have any better suggestion than yours.

        1. andrewbares7 says:

          You can clone and build/deploy our universal dismiss selfhost app! It’s on GitHub here: https://github.com/WindowsNotifications/UniversalDismissSelfhostApp

          Deploy it on both devices, make sure you’re logged into Cortana on both too, and then you can click the button on both devices to schedule a toast for 10 secs in the future. Note that you might have to try it twice -make sure the RemoteId matches on both devices.

          1. Thanks, works great 🙂