Skip to content

Commit

Permalink
Adding explicit links to RequestAccessAsync methods
Browse files Browse the repository at this point in the history
Github issue #3221 - No link to explain how to obtain access to run background tasks
  • Loading branch information
drewbatgit authored Jul 9, 2021
1 parent c119cab commit 2ca049d
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ listener.ClearNotifications();

A common way to enable an app to listen to notifications is to set up a background task, so that you can know when a notification was added or dismissed regardless of whether your app is currently running.

Thanks to the [single process model](/windows/uwp/launch-resume/create-and-register-an-inproc-background-task) added in the Anniversary Update, adding background tasks is fairly simple. In your main app's code, after you have obtained the user's access to Notification Listener and obtained access to run background tasks, simply register a new background task, and set the [UserNotificationChangedTrigger](/uwp/api/windows.applicationmodel.background.usernotificationchangedtrigger) using the [Toast notification kind](/uwp/api/windows.ui.notifications.notificationkinds).
Thanks to the [single process model](/windows/uwp/launch-resume/create-and-register-an-inproc-background-task) added in the Anniversary Update, adding background tasks is fairly simple. In your main app's code, after you have obtained the user's access to Notification Listener and obtained access to run background tasks by calling [UserNotificationListener.Current.RequestAccessAsync](/uwp/api/windows.ui.notifications.management.usernotificationlistener.requestaccessasync) and [BackgroundExecutionManager.RequestAccessAsync](/uwp/api/windows.applicationmodel.background.backgroundexecutionmanager.requestaccessasync) respectively, simply register a new background task, and set the [UserNotificationChangedTrigger](/uwp/api/windows.applicationmodel.background.usernotificationchangedtrigger) using the [Toast notification kind](/uwp/api/windows.ui.notifications.notificationkinds).

```csharp
// TODO: Request/check Listener access via UserNotificationListener.Current.RequestAccessAsync
Expand Down

0 comments on commit 2ca049d

Please sign in to comment.