1# @ohos.data.unifiedDataChannel (Unified Data Channel) (System API) 2 3As a part of the Unified Data Management Framework (UDMF), the **unifiedDataChannel** module provides APIs to control the sharing range of the data in the drag data channel. 4 5> **NOTE** 6> 7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.data.unifiedDataChannel](js-apis-data-unifiedDataChannel.md). 10 11## Import modules. 12 13```ts 14import { unifiedDataChannel } from '@kit.ArkData'; 15``` 16 17## Intention 18 19Enumerates the data channel types supported by the UDMF. It is used to identify different service scenarios, to which the UDMF data channels apply. 20 21**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 22 23| Name| Value | Description | 24| ---- | ------ | ----------------------------------- | 25| DRAG<sup>12+</sup> | 'Drag' | Channel in which data can be dragged.<br>**Model restriction**: This API can be used only in the stage model.<br>**System API**: This is a system API.| 26 27## unifiedDataChannel.setAppShareOptions<sup>12+</sup> 28 29setAppShareOptions(intention: Intention, shareOptions: ShareOptions): void 30 31Sets the [ShareOptions](js-apis-data-unifiedDataChannel.md#shareoptions12) for the application data. Currently, only the drag data channel is supported. 32 33**Model restriction**: This API can be used only in the stage model. 34 35**System API**: This is a system API. 36 37**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 38 39**Parameters** 40 41| Name | Type | Mandatory| Description | 42|----------|----------------------------|----|------------------------------| 43| intention | [Intention](#intention) | Yes | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.| 44| shareOptions | [ShareOptions](js-apis-data-unifiedDataChannel.md#shareoptions12) | Yes | Sharing range of the [UnifiedData](js-apis-data-unifiedDataChannel.md#unifieddata).| 45 46**Error codes** 47 48For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [UDMF Error Codes](errorcode-udmf.md). 49 50| **ID**| **Error Message** | 51| ------------ | ------------------------------------------------------------ | 52| 202 | Permission verification failed, application which is not a system application uses system API. | 53| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 54| 20400001 | Settings already exist. | 55 56**Example** 57 58```ts 59import { BusinessError } from '@kit.BasicServicesKit'; 60try { 61 unifiedDataChannel.setAppShareOptions(unifiedDataChannel.Intention.DRAG, unifiedDataChannel.ShareOptions.IN_APP); 62 console.info(`[UDMF]setAppShareOptions success. `); 63}catch (e){ 64 let error: BusinessError = e as BusinessError; 65 console.error(`[UDMF]setAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `); 66} 67``` 68 69## unifiedDataChannel.removeAppShareOptions<sup>12+</sup> 70 71removeAppShareOptions(intention: Intention): void 72 73Removes the data control set by [setAppShareOptions](#unifieddatachannelsetappshareoptions12). 74 75**Model restriction**: This API can be used only in the stage model. 76 77**System API**: This is a system API. 78 79**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 80 81**Parameters** 82 83| Name | Type | Mandatory| Description | 84| --------- | ----------------------- | ---- | ------------------------------------------------------------ | 85| intention | [Intention](#intention) | Yes | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.| 86 87**Error codes** 88 89For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 90 91| **ID**| **Error Message** | 92| ------------ | ------------------------------------------------------------ | 93| 202 | Permission verification failed, application which is not a system application uses system API. | 94| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. | 95 96**Example** 97 98```ts 99import { BusinessError } from '@kit.BasicServicesKit'; 100try { 101 unifiedDataChannel.removeAppShareOptions(unifiedDataChannel.Intention.DRAG); 102 console.info(`[UDMF]removeAppShareOptions success. `); 103}catch (e){ 104 let error: BusinessError = e as BusinessError; 105 console.error(`[UDMF]removeAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `); 106} 107``` 108