• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Requesting Permissions to Access the Pasteboard
2
3## Overview
4
5In API version 12 and later, permission control is added to the pasteboard reading API to enhance user privacy protection.
6
7Related APIs:
8
9| Name| Description                                                                                                                                       |
10| -------- |----------------------------------------------------------------------------------------------------------------------------------------|
11| getData( callback: AsyncCallback<PasteData>): void | Reads a **PasteData** object from the pasteboard. This API uses an asynchronous callback to return the result.|
12| getData(): Promise<PasteData> | Reads a **PasteData** object from the pasteboard. This API uses a promise to return the result.|
13| getDataSync(): PasteData | Reads data from the system pasteboard. This API returns the result synchronously.|
14| getUnifiedData(): Promise\<udc.UnifiedData\> | Reads the data of a unified data object from the system pasteboard.|
15| getUnifiedDataSync(): udc.UnifiedData | Reads the data of a unified data object from the system pasteboard. This API returns the result synchronously.|
16| OH_UdmfData * OH_Pasteboard_GetData (OH_Pasteboard *pasteboard, int *status) | Obtains data from the pasteboard.|
17
18## Accessing Pasteboard Content
19
20Applications can access the pasteboard content in either of the following ways:
21
22- Using security components
23
24    Applications that use the [security components](../../security/AccessToken/pastebutton.md) to access the pasteboard content do not need to request the permission.
25
26    Applications that use the security components can access the pasteboard content without any adaptation.
27
28- Requesting the **ohos.permission.READ_PASTEBOARD** permission
29
30    **ohos.permission.READ_PASTEBOARD** is a restricted user_grant permission. Applications that use customized components can request the **ohos.permission.READ_PASTEBOARD** permission to access the pasteboard content with user authorization.
31
32    How to request permissions:
33    <!--RP1-->
34    1. Apply for high-level permissions through [ACL](../../security/AccessToken/declare-permissions-in-acl.md).
35
36    2. [Declare permissions](../../security/AccessToken/declare-permissions.md) in the **module.json5** configuration file.
37
38    3. [Request user authorization](../../security/AccessToken/request-user-authorization.md) in a dialog box.
39    <!--RP1End-->
40