[UWP] BackgroundTask显示Toast通知场景 [英] [UWP] BackgroundTask showing toast notification scenario

查看:104
本文介绍了[UWP] BackgroundTask显示Toast通知场景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个UWP应用程序,其中的场景解释如下:



场景 -  

 我们有一个应用程序,它有一个app服务,它注册一个BackgroundTask(说出名字:A)(Trigger:TimeTrigger)。此backgroundTask定期向用户显示Toast通知。使用'NotificationActionBackgroundTask'
类显示通知。吐司有与之相关的按钮,显示"稍后提醒我"等文字。  我们必须在不启动应用程序的情况下处理Toast通知的按钮点击事件。



示例 -

 考虑一个警报的使用案例,每小时触发一次。一小时后会发出此警报以显示一些Toast通知。这个吐司有按钮,如'贪睡'或'不要打扰我'。单击这些按钮时,应用程序不会启动
,但某些事件处理是在后台完成的。如果用户点击"暂停",则下一个要显示的吐司会延迟一段时间。 



我们的解决方案 -

 我们创建了另一个BackgroundTask(Say name:B)(Trigger:ToastNotificationActionTrigger),它使用通过'ToastNotificationActionTriggerDetail'传递的参数来处理Toast通知的按钮点击事件。这个处理
是在没有启动应用程序的情况下完成的。 
$


我们的问题是,我们的方法是正确的吗? 

如果没有,还有其他优雅的方法来处理这种情况。请建议是否。

We are developing a UWP app, where the scenario is explained as below :

Scenario - 
 We have an app, which has an app service, which registers a BackgroundTask (Say name : A) (Trigger : TimeTrigger). This backgroundTask shows toast notifications to the user, on regular intervals. The notifications are showed using the ‘NotificationActionBackgroundTask’ class. The toast has buttons associated with it, showing texts like ‘Remind me later’.  We have to handle button on-click event of the toast notification without launching the app.

Example -
 Consider an use case of the alarm, which is triggered every hour. This alarm triggers after an hour to show some toast notification. This toast has buttons like ‘Snooze’ or ‘Don’t bother me’. On clicking these buttons, the application is not launched but some event handling is done at the background. If the user clicks on ‘Snooze’, the next toast to be shown is delayed by some time. 

Our solution -
 We have created one more BackgroundTask (Say name : B) (Trigger : ToastNotificationActionTrigger) which handles the button on-click event of the toast notification, using arguments passed with the ‘ToastNotificationActionTriggerDetail’. This handling is done without launching the app. 

Our question to you is that, is our approach the right one? 
If not, is there any other elegant way to handle this scenario. Please suggest if any.

推荐答案

您好,


是的,你是对的。从Toast通知处理后台激活是使用ToastNotificationActionTrigger,如下文所述。

https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/08/quickstart - 发送 - 本地 - 吐司 - 通知和处理 - 激活 - 来自Windows-10 /  



最好的问候,

David
Hi,

Yes, you are right. Handling background activation from a toast notification is to use the ToastNotificationActionTrigger as the following article describes.
https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/08/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10/ 

Best Regards,
David


这篇关于[UWP] BackgroundTask显示Toast通知场景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆