【发布时间】:2020-04-06 09:05:46
【问题描述】:
我使用this 之后的以下代码测试了 toast 通知:
public static void ShowToastNotification(string message)
{
ToastContent content = new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = message
}
}
}
}
};
ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
}
Manifest 如下所示:
<VisualElements>
...
<uap:LockScreen BadgeLogo="Assets\BadgeLogo.png" Notification="badgeAndTileText"/>
...
</VisualElements>
...
<BackgroundTasks>
...
<Task Type="pushNotification"/>
...
</BackgroundTasks>
但屏幕锁定时它永远不会弹出。
-
几秒内解锁就可以看到了。
-
如果我在 15 秒后解锁,我看不到通知,因为我将持续时间设置为短。
我检查了以下设置:
当我在包清单中声明后台任务时,我启用了推送通知,
我在 Windows 设置中开启了“在锁定屏幕上显示通知”,
并且我在 Windows 设置中启用了我的应用在后台运行。
我可以看到它命中了后台任务(因为后台工作中的其他功能)。
我错过了什么??
如果有办法改为更改 WELCOME MESSAGE,那也适用于我。
我正在寻找一种在登录期间发生错误时通知用户的方法。
任何帮助表示赞赏:)
【问题讨论】:
-
你用过
ToastNotifier吗?
标签: c# uwp windows-10 windows-runtime windows-10-universal