question

AbbojuMounikaCW-8333 avatar image
0 Votes"
AbbojuMounikaCW-8333 asked RoyLi-MSFT edited

How to implement text as HyperLink in Toast windows using xml?

I am trying to implement the Hyperlink in windows toast which accepts xml as a string as per the documents i couldn't find a way to implement hyperlink in text
Example:
I need to display a text in toast as: To get more details. click here

here the click here should work as a link which opens a page in browser.


Note: it accepts only XML link to follow:https://docs.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=xml#text-elements

windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AbbojuMounikaCW-8333 Hope you've been well. Have you solved your issue?

0 Votes 0 ·

1 Answer

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered

Hello,

Welcome to Microsoft Q&A!

How to implement text as HyperLink in Toast windows using xml?

I've checked the document and the sample about sending toast notification. It seems that adding HyperLink is not supported in the toast notification. Another thing is that, when click the Toast notification, the click event should be handled by the app not a different browser.

My suggestion is that you could handle the activation in your app when the user click on the toast notification. Then you could navigate to a new page and use a WebView to show the link as you want. So you don't need to launch a broswer instead.

Like this:

         protected override void OnActivated(IActivatedEventArgs args)
         {
    
             Frame rootFrame = Window.Current.Content as Frame;
             // Handle notification activation
             if (args is ToastNotificationActivatedEventArgs toastActivationArgs)
             {
                 // Obtain the arguments from the notification
                 ToastArguments argument = ToastArguments.Parse(toastActivationArgs.Argument);
    
                 // Obtain any user input (text boxes, menu selections) from the notification
                 ValueSet userInput = toastActivationArgs.UserInput;
    
                 // TODO: Show the corresponding content
    
                 rootFrame.Navigate(typeof(TargetPage));
             }
    
             // Ensure the current window is active
             Window.Current.Activate();
         }


Or if you still want to use the browser of you system, you could also launch the default broswer for your UWP app via Launcher.LaunchUriAsync

For more information about handling the activation of the toast notification, please check: Send a local toast notification from C# apps

Thank you.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.