• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Requesting Permissions to Access the Pasteboard
2<!--Kit: Basic Services Kit-->
3<!--Subsystem: MiscServices-->
4<!--Owner: @yangxiaodong41-->
5<!--Designer: @guo867-->
6<!--Tester: @maxiaorong2-->
7<!--Adviser: @HelloCrease-->
8
9## Overview
10
11In API version 12 and later, permission control is added to the pasteboard reading API to enhance user privacy protection.
12
13Related APIs:
14
15| Name| Description                                                                                                                                       |
16| -------- |----------------------------------------------------------------------------------------------------------------------------------------|
17| getData(callback: AsyncCallback&lt;PasteData&gt;): void | Reads a **PasteData** object from the pasteboard. This API uses an asynchronous callback to return the result.|
18| getData(): Promise&lt;PasteData&gt; | Reads a **PasteData** object from the pasteboard. This API uses a promise to return the result.|
19| getDataSync(): PasteData | Reads data from the system pasteboard. This API returns the result synchronously.|
20| getUnifiedData(): Promise\<unifiedDataChannel.UnifiedData\> | Reads the data of a unified data object from the system pasteboard.|
21| getUnifiedDataSync(): unifiedDataChannel.UnifiedData | Reads the data of a unified data object from the system pasteboard. This API returns the result synchronously.|
22| OH_UdmfData* OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status) | Obtains data from the pasteboard.|
23| getDataWithProgress(params: GetDataParams): Promise\<PasteData\> | Obtains the pasteboard data and paste progress. This API uses a promise to return the result. Folders cannot be copied.|
24| OH_UdmfData* OH_Pasteboard_GetDataWithProgress(OH_Pasteboard* pasteboard, Pasteboard_GetDataParams* params, int* status) | Obtains the pasteboard data and paste progress. Folders cannot be copied.|
25
26## Accessing Pasteboard Content
27
28Applications can access the pasteboard content in either of the following ways:
29
30- Using security components
31
32    Applications that use [security components](../../security/AccessToken/pastebutton.md) to access the pasteboard content do not need to request the permission.
33
34    Applications that use the security components can access the pasteboard content without any adaptation.
35
36- Requesting the ohos.permission.READ_PASTEBOARD permission
37
38    ohos.permission.READ_PASTEBOARD is a restricted user_grant permission. Applications that use custom components can request this permission to access the pasteboard content with user authorization.
39
40    How to request permissions:
41    <!--RP1-->
42    1. Request high-level permissions through [ACL](../../security/AccessToken/declare-permissions-in-acl.md).
43
44    2. [Declare permissions](../../security/AccessToken/declare-permissions.md) in the **module.json5** configuration file.
45
46    3. [Request user authorization](../../security/AccessToken/request-user-authorization.md) via a dialog box.
47    <!--RP1End-->
48