Reputation: 47
Outlook add-in VSTO project cannot override App logo when sending local notification, ends up without text or logo when using .AddAppLogoOverride()
private void CallNotification()
{
CreateToastNotification("This is test header", "First line of notification", "...second line...");
}
public void CreateToastNotification(string title, string message, string message2)
{
ToastContent content = new ToastContentBuilder()
.AddText(title)
.AddText(message)
.AddText(message2)
.AddAppLogoOverride(new Uri("/component/logo.png", UriKind.Relative), ToastGenericAppLogoCrop.Circle)
.AddAttributionText("My notification service")
.AddButton(new ToastButton()
.SetContent("Open Google")
.AddArgument("url", "https://google.com"))
.AddButton(new ToastButton()
.SetContent("Dismiss")
.AddArgument("dismiss", "dismiss"))
.SetToastDuration(ToastDuration.Long)
.GetToastContent();
// Creates the notification
ToastNotification notification = new ToastNotification(content.GetXml());
//set expiration poilicies
notification.ExpirationTime = DateTime.Now.AddMinutes(120);
//add handlers
notification.Activated += ToastNotificationCallback_Activated;
notification.Dismissed += Notification_Dismissed;
notification.Failed += Notification_Failed;
//Adds toast notification to list to persist toast
toastNotificationList.Add(notification);
//Sends the notification
//do not forget to add APPID to CreateToastNotifier()
//https://stackoverflow.com/questions/32214716/showing-a-windows-10-toast-notification
ToastNotificationManager.CreateToastNotifier("MyAppID").Show(notification);
}
My logo.png exists and is copied to output dir
And result is generic notification without passed text or icon
When I comment .AddAppLogoOverride()
shows text, but without logo.
Any idea what could be wrong? Maybe Uri?
Upvotes: 0
Views: 1139
Reputation: 47
Edit: Following works only for first notification, if app sends notification again there is same result as previously (no icon but with text). Still looking for help with this, thanks.
Ok, it was problem with Uri. This line works:
.AddAppLogoOverride(new Uri("file:///"+Path.GetFullPath(@"component\logo.png"), UriKind.Absolute), ToastGenericAppLogoCrop.Circle)
Upvotes: 1