-
Notifications
You must be signed in to change notification settings - Fork 391
Description
Proposal: Enable UWP apps to request background access to the clipboard
This proposal was originally tailored to the specific use case of allowing UWP apps running in the background access to the clipboard when interacted with via toast notifications. In follow-up discussions it was then suggested to increase the scope of this issue to cover background access to the clipboard for UWP apps in general. This proposal has thus been edited to reflect the broadened scope.
Summary
Currently, the UWP Clipboard APIs only allow (read/write) access to the clipboard when the calling UWP app is the foregroud app. In other words, these APIs will "fail" if your UWP app is currently running in the background. However, there are use cases where UWP apps running in the background should be allowed to have access to the clipboard in order to provide a delightful user experience (see for example the scenario described in this comment.
As a workaround for this current app model limitation, UWP apps can use a Win32 full-trust helper process (via an app service) and call the Win32 Clipboard APIs to access the clipboard to read from/write to the clipboard even when in the background.
This proposal aims to improve the UWP Clipboard APIs so that UWP apps can request clipboard access when in the background. This request model follows the typical UWP permission model - an initial background clipboard access request will prompt a user-consent dialog with access only being granted if the user agrees to the request. If the user denies the request, no background access to the clipboard for the app is granted. As long as the user did not revoke previously granted background access for an UWP, each subsequent request call will be "silent-accept", in other words, no user-consent dialog prompt will be shown.
Rationale
Developers should not have to resort to using a win32 full-trust process to realize UWP app experiences where (selective) clipboard background access is essential to create delightful user experiences. Some significant drawbacks of having to consume a win32 full-trust helper process alongside your UWP app are the following:
- UWP apps have the restricted
runFullTrust
app capability: This can cause security concerns for potential app customers - in the worst case leading them to not use your app - Additional development complexity is added due to having to set up the win32 full-trust helper process and enable back-and-forth communication between it and the main UWP app. See the documentation for more details about how app service communication works.
Scope
Capability | Priority |
---|---|
Allow UWP apps running in the background to request read/write access to the clipboard and if the user agrees to the request, access is granted. | Must |
The user can revoke granted background clipboard access for a (UWP) app in Windows Settings at any given point. | Must |
Change the current clipboard foreground access behavior to also ask for specific user agreement if required. | Won't |
API Details
A conceptual API overview can be found in this comment: #62 (comment)
Additional Context
This topic (particulary the app scenario with backgroudn clipboard access following toast notification interaction) was initially brought up in the WinUI repo and @BenJKuhn already gave some first thoughts on it (see [Clipboard Pains]):
That said, a notification that’s being interacted with seems like it should be allowed clipboard access. This would require special handling because of how Windows and foreground is counted, I think, but doesn’t seem beyond reasonable.
A Feedback Hub entry about this issue can be found here: https://aka.ms/AA7zx69