吐司不显示

vix*_*xez 3 c# notifications toast windows-10 uwp

我正在尝试显示一个简单的吐司,它显示了我部署应用程序的第一个,但它不再显示。我没有对部署之间的代码进行任何更改。这是基本的空白项目,除了在 Mainpage 这是唯一的代码

   public MainPage()
    {
        this.InitializeComponent();
    }

    public static void Notification(string title, string content)
    {
        // Construct the visuals of the toast
        ToastVisual visual = new ToastVisual()
        {
            TitleText = new ToastText()
            {
                Text = title
            },

            BodyTextLine1 = new ToastText()
            {
                Text = content,
            },

        };


        ToastContent toastContent = new ToastContent()
        {
            Visual = visual,
        };

        // And create the toast notification
        Windows.Data.Xml.Dom.XmlDocument doc = toastContent.GetXml();
        var toast = new ToastNotification(toastContent.GetXml());

        ToastNotificationManager.CreateToastNotifier().Show(toast);
    }


    private void buttonShowToast_Tapped(object sender, TappedRoutedEventArgs e)
    {
        Notification("a", "b");
    }
Run Code Online (Sandbox Code Playgroud)

已安装 NuGet 包:NotificationExtensions.Win10(版本:14332.0.2)

这很简单,为什么它不起作用?我是否缺少某种许可?

vix*_*xez 5

我想到了。出于某种原因,Windows 10 禁用了使用 Visual Studio 部署的所有应用程序的通知。转到设备设置中的“通知和操作”,在“从这些发件人处获取通知”下关闭了权限。

将应用程序的权限切换为“打开”解决了这个问题。

  • Visual Studio 没有被列为我的任何发件人:( (2认同)