Home > Mobile >  How to add "clipboard-write" permission to navigator?
How to add "clipboard-write" permission to navigator?

Time:12-13

I am maintaining an app written in Angular and launched on chromium (desktop app), i am trying to copy to clipboard some text and i used

navigator.clipboard.writeText(result)

Unfortunately, it didn't work because and i don't have "clipboard-write" permission on the navigator.

How to add permission "clipboard-write" to the navigator or is there any other solution to copy the text to the clipboard ?

CodePudding user response:

How to add permission "clipboard-write" to the navigator?

Permissions are not something that you (as the developer) control. They are entirely within the control of the user and user agent (browser). If the user decides not to grant (or revoke) a permission, then your app simply cannot perform actions which require it.

I'll inline some documentation from the MDN article for Clipboard.writeText():

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

The "clipboard-write" permission of the Permissions API is granted automatically to pages when they are in the active tab.

  • Related