Skip to content

Instantly share code, notes, and snippets.

@cnbluefire
Created August 7, 2025 14:44
Show Gist options
  • Select an option

  • Save cnbluefire/7c4ffc51d830a4176643387c7541f7ee to your computer and use it in GitHub Desktop.

Select an option

Save cnbluefire/7c4ffc51d830a4176643387c7541f7ee to your computer and use it in GitHub Desktop.
Create a Windows notification to open a url using Edge.
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
// Edge Package AUMID
const string AUMID = "Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe!App";
var notifier = ToastNotificationManager.CreateToastNotifier(AUMID);
var xml = $$$"""
<toast launch='{{{BuildLaunchId(new Uri("https://www.4399.com/"))}}}'>
<visual>
<binding template='ToastGeneric'>
<text>Open Website</text>
</binding>
</visual>
<actions>
<action content='Open' arguments='{{{BuildLaunchId(new Uri("https://www.7k7k.com/"))}}}'/>
</actions>
</toast>
""";
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
var notification = new ToastNotification(xmlDoc);
notifier.Show(notification);
static string BuildLaunchId(Uri uri) =>
// https://github.com/chromium/chromium/blob/9fb86dba30189c2d48982de69ee6d5031391248d/chrome/browser/notifications/win/notification_launch_id.cc#L87
// type|notification_type|profile_id|app_user_model_id|incognito|origin|notification_id
$"0|1|Default|MSEdge|0|{uri.OriginalString}|";
@cnbluefire

Copy link
Copy Markdown
Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment