0

I am building a notification service and I am currently facing an issue when trying to display any kind of image in it.
I am using Microsoft.Toolkit.Uwp.Notifications and below is the code I am using to show build and show the notification.

static class NotificationTemplate
{
    public static ToastContentBuilder HelpDesk(string main_payload, string additional_data, string type)
    {
        return new ToastContentBuilder()
                  .AddArgument("type", "helpdesk")
                  .AddArgument("select", main_payload)
                  .AddText("Incoming ticket", AdaptiveTextStyle.Title)
                  .AddText(type, AdaptiveTextStyle.Header)
                  .AddAttributionText(additional_data)
                  .AddAppLogoOverride(new Uri("https://cdn4.iconfinder.com/data/icons/the-weather-is-nice-today/64/weather_11-64.png"))
                  .AddButton(new ToastButton()
                      .AddArgument("take", main_payload)
                      .SetContent("TAKE"))
                  .AddButton(new ToastButton()
                      .AddArgument("close", main_payload)
                      .SetContent("CLOSE"));
    }

}

The image I use in the Uri is valid(a test link, not the actual thing) and is shown when opening the link in a browser. Below is a screenshot of the shown notification:
Notification showing without image

I am running Windows 10 build 19045.3324

CodeJunkie
  • 263
  • 2
  • 11
  • Is your app packaged? IIRC, HTTP / HTTPS resources are supported when the app is packaged and manifested, specifying Internet capabilities, otherwise you use `ms-appdata:///local/` – Jimi Aug 16 '23 at 12:05
  • It is not packaged. So I need to store the images locally ? – CodeJunkie Aug 16 '23 at 12:11
  • You can store image into local and update build type resouces https://stackoverflow.com/questions/50853578/i-want-to-access-resources-in-uwp – Anant Dabhi Aug 16 '23 at 12:12
  • @AnantDabhi is this the same for WinForms ? As I created an assets folder and added test.png to it. I then set the test.png build to `resource` and `copy if newer` and created the following path `ms-appx:///Assets/test.png` according to the link you sent, but now it doesn't even show the rest of the notification(text, buttons etc) – CodeJunkie Aug 16 '23 at 12:26
  • `ms-appx://` it's a schema that defines resources that come from the app's package. Your app is not packaged – Jimi Aug 16 '23 at 13:07
  • I clearly stated that the app isn't packaged. Idk why Anant even suggested it – CodeJunkie Aug 16 '23 at 16:55
  • @Jimi How do I work around this ? What is the solution ? – CodeJunkie Aug 16 '23 at 16:55
  • IMO, the best thing you can do is to package your app. Nothing fancy, add a packaging Project, so your app gets manifested correctly. Add your Project's reference to the package, edit the manifest to specify Internet capabilities (and whatever else you find necessary) – Jimi Aug 17 '23 at 01:10
  • I am wondering if this should work while in debug mode or do I have to use the package to install the app ? – CodeJunkie Aug 17 '23 at 06:53

0 Answers0