From 40c6c802e9783b31456b4b002d4a88ba4dfffaf2 Mon Sep 17 00:00:00 2001 From: Gloria Date: Tue, 14 Mar 2023 20:11:01 +0800 Subject: [PATCH] Update docs against 15406 Signed-off-by: wusongqing --- .../reference/apis/js-apis-device-manager.md | 140 +++++++++++++++++- 1 file changed, 134 insertions(+), 6 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-device-manager.md b/en/application-dev/reference/apis/js-apis-device-manager.md index 60e97b6913..bd78aa4b49 100644 --- a/en/application-dev/reference/apis/js-apis-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-device-manager.md @@ -131,12 +131,12 @@ Defines subscription information. | Name | Type | Mandatory | Description | | ------------- | --------------------------------- | ---- | ----------------- | | subscribeId | number | Yes | Subscription ID, used to identify a device discovery period.| -| mode | [DiscoverMode ](#discovermode) | No | Device discovery mode. | -| medium | [ExchangeMedium](#exchangemedium) | No | Medium used for device discovery. | -| freq | [ExchangeFreq](#exchangefreq) | No | Frequency of device discovery. | -| isSameAccount | boolean | No | Whether the same account is used on the discovered device. | -| isWakeRemote | boolean | No | Whether to wake up the discovered device. | -| capability | [SubscribeCap](#subscribecap) | No | Discovery capability. | +| mode | [DiscoverMode ](#discovermode) | Yes | Device discovery mode. | +| medium | [ExchangeMedium](#exchangemedium) | Yes | Medium used for device discovery. | +| freq | [ExchangeFreq](#exchangefreq) | Yes | Frequency of device discovery. | +| isSameAccount | boolean | Yes | Whether the same account is used on the discovered device. | +| isWakeRemote | boolean | Yes | Whether to wake up the discovered device. | +| capability | [SubscribeCap](#subscribecap) | Yes | Discovery capability. | ## DiscoverMode @@ -874,6 +874,134 @@ Sets a user operation. } ``` +### requestCredentialRegisterInfo10+ + +requestCredentialRegisterInfo(requestInfo: string, callback: AsyncCallback<{registerInfo: string}>): void; + +Obtains the registration information of the credential. + +**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** + + | Name | Type | Mandatory | Description | + | ------------- | --------------- | ---- | ------------------- | + | requestInfo | string | Yes | Request credential information. | + | callback | AsyncCallback<{registerInfo: string}> | Yes | Callback used to return the credential registration information.| + +**Example** + + ```js + let credentialInfo = { + "version" : "1.2.3", + "userId" : "123" + } + try { + dmClass.requestCredentialRegisterInfo(credentialInfo, (data) => { + if (data) { + console.info("requestCredentialRegisterInfo result:" + JSON.stringify(data)); + } else { + console.info.push("requestCredentialRegisterInfo result: data is null"); + } + }); + } catch (err) { + console.error("requestCredentialRegisterInfo err:" + err.code + "," + err.message); + } + ``` + +### importCredential10+ + +importCredential(credentialInfo: string, callback: AsyncCallback<{resultInfo: string}>): void; + +Imports credential information. + +**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** + + | Name | Type | Mandatory | Description | + | ------------- | --------------- | ---- | ------------------- | + | credentialInfo| string | Yes | Credential information to import. | + | callback | AsyncCallback<{resultInfo: string}> | Yes | Callback used to return the result.| + +**Example** + + ```js + let credentialInfo = { + "processType" : 1, + "authType" : 1, + "userId" : "123", + "deviceId" : "aaa", + "version" : "1.2.3", + "devicePk" : "0000", + "credentialData" : + [ + { + "credentialType" : 2, + "credentialId" : "102", + "serverPk" : "3059301306072A8648CE3D020106082A8648CE3D03", + "pkInfoSignature" : "30440220490BCB4F822004C9A76AB8D97F80041FC0E", + "pkInfo" : "", + "authCode" : "", + "peerDeviceId" : "" + } + ] + } + try { + dmClass.importCredential(credentialInfo, (data) => { + if (data) { + console.info("importCredential result:" + JSON.stringify(data)); + } else { + console.info.push("importCredential result: data is null"); + } + }); + } catch (err) { + console.error("importCredential err:" + err.code + "," + err.message); + } + ``` + +### deleteCredential10+ + +deleteCredential(queryInfo: string, callback: AsyncCallback<{resultInfo: string}>): void; + +Deletes credential information. + +**Required permissions**: ohos.permission.ACCESS_SERVICE_DM (available only to system applications) + +**System capability**: SystemCapability.DistributedHardware.DeviceManager + +**Parameters** + + | Name | Type | Mandatory | Description | + | ------------- | --------------- | ---- | ------------------- | + | queryInfo | string | Yes | Credential information to delete. | + | callback | AsyncCallback<{resultInfo: string}> | Yes | Callback used to return the result.| + +**Example** + + ```js + let queryInfo = { + "processType" : 1, + "authType" : 1, + "userId" : "123" + } + try { + dmClass.deleteCredential(queryInfo, (data) => { + if (data) { + console.info("deleteCredential result:" + JSON.stringify(data)); + } else { + console.info.push("deleteCredential result: data is null"); + } + }); + } catch (err) { + console.error("deleteCredential err:" + err.code + "," + err.message); + } + ``` + ### on('uiStateChange')9+ on(type: 'uiStateChange', callback: Callback<{ param: string}>): void; -- GitLab