提交 e5f4b037 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 3e766c2e
...@@ -64,7 +64,7 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -64,7 +64,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. | | 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example** **Example**
...@@ -74,7 +74,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; ...@@ -74,7 +74,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try { try {
atManager.checkAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => { atManager.checkAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`checkAccessToken success, data->${JSON.stringify(data)}`); console.log(`checkAccessToken success, data->${JSON.stringify(data)}`);
}).catch((err) => { }).catch((err) => {
console.log(`checkAccessToken fail, err->${JSON.stringify(err)}`); console.log(`checkAccessToken fail, err->${JSON.stringify(err)}`);
...@@ -111,14 +111,14 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -111,14 +111,14 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. | | 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example** **Example**
```js ```js
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.verifyAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let data = atManager.verifyAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`); console.log(`data->${JSON.stringify(data)}`);
``` ```
...@@ -154,7 +154,7 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -154,7 +154,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0, the permissionName is greater than 256 bytes, or the flags value is invalid. | | 12100001 | The parameter is invalid. The tokenID is 0, the permissionName exceeds 256 bytes, or the flags value is invalid. |
| 12100002 | The specified tokenID does not exist. | | 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. | | 12100003 | The specified permission does not exist. |
| 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. | | 12100006 | The application specified by the tokenID is not allowed to be granted with the specified permission. Either the application is a sandbox or the tokenID is from a remote device. |
...@@ -169,7 +169,7 @@ let atManager = abilityAccessCtrl.createAtManager(); ...@@ -169,7 +169,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1; let permissionFlags = 1;
try { try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => { atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('grantUserGrantedPermission success'); console.log('grantUserGrantedPermission success');
}).catch((err) => { }).catch((err) => {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`); console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
...@@ -221,7 +221,7 @@ let atManager = abilityAccessCtrl.createAtManager(); ...@@ -221,7 +221,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1; let permissionFlags = 1;
try { try {
atManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => { atManager.grantUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) { if (err) {
console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`); console.log(`grantUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else { } else {
...@@ -280,7 +280,7 @@ let atManager = abilityAccessCtrl.createAtManager(); ...@@ -280,7 +280,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1; let permissionFlags = 1;
try { try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags).then(() => { atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags).then(() => {
console.log('revokeUserGrantedPermission success'); console.log('revokeUserGrantedPermission success');
}).catch((err) => { }).catch((err) => {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`); console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
...@@ -332,7 +332,7 @@ let atManager = abilityAccessCtrl.createAtManager(); ...@@ -332,7 +332,7 @@ let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let permissionFlags = 1; let permissionFlags = 1;
try { try {
atManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlags, (err, data) => { atManager.revokeUserGrantedPermission(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS', permissionFlags, (err, data) => {
if (err) { if (err) {
console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`); console.log(`revokeUserGrantedPermission fail, err->${JSON.stringify(err)}`);
} else { } else {
...@@ -375,7 +375,7 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -375,7 +375,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. | | 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
| 12100002 | The specified tokenID does not exist. | | 12100002 | The specified tokenID does not exist. |
| 12100003 | The specified permission does not exist. | | 12100003 | The specified permission does not exist. |
| 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. | | 12100006 | The operation is not allowed. Either the application is a sandbox or the tokenID is from a remote device. |
...@@ -389,7 +389,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; ...@@ -389,7 +389,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
try { try {
atManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS").then((data) => { atManager.getPermissionFlags(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS').then((data) => {
console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`); console.log(`getPermissionFlags success, data->${JSON.stringify(data)}`);
}).catch((err) => { }).catch((err) => {
console.log(`getPermissionFlags fail, err->${JSON.stringify(err)}`); console.log(`getPermissionFlags fail, err->${JSON.stringify(err)}`);
...@@ -443,7 +443,7 @@ Subscribes to permission state changes of the specified applications and permiss ...@@ -443,7 +443,7 @@ Subscribes to permission state changes of the specified applications and permiss
| ------------------ | --------------------- | ---- | ------------------------------------------------------------ | | ------------------ | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Event type to subscribe to. The value is **'permissionStateChange'**, which indicates the permission grant state change. | | type | string | Yes | Event type to subscribe to. The value is **'permissionStateChange'**, which indicates the permission grant state change. |
| tokenIDList | Array&lt;number&gt; | Yes | Token IDs of the applications to observe. If this parameter is left empty, the permission grant state changes of all applications are observed. | | tokenIDList | Array&lt;number&gt; | Yes | Token IDs of the applications to observe. If this parameter is left empty, the permission grant state changes of all applications are observed. |
| permissionList | Array&lt;Permissions&gt; | Yes | Permissions to observe. If this parameter is left empty, the grant state changes of all permissions are observed. | | permissionList | Array&lt;Permissions&gt; | Yes | List of permission names. If this parameter is left empty, the grant state changes of all permissions are subscribed to. |
| callback | Callback&lt;[PermissionStateChangeInfo](#permissionstatechangeinfo9)&gt; | Yes| Callback invoked to return the permission grant state change.| | callback | Callback&lt;[PermissionStateChangeInfo](#permissionstatechangeinfo9)&gt; | Yes| Callback invoked to return the permission grant state change.|
**Error codes** **Error codes**
...@@ -452,7 +452,7 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -452,7 +452,7 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. | | 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
| 12100004 | The interface is called repeatedly with the same input. | | 12100004 | The interface is called repeatedly with the same input. |
| 12100005 | The registration time has exceeded the limitation. | | 12100005 | The registration time has exceeded the limitation. |
| 12100007 | Service is abnormal. | | 12100007 | Service is abnormal. |
...@@ -461,16 +461,16 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -461,16 +461,16 @@ For details about the error codes, see [Application Access Control Error Codes](
**Example** **Example**
```js ```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; import {Permissions} from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100); let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array<number> = [appInfo.accessTokenId]; let tokenIDList: Array<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"]; let permissionList: Array<Permissions> = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try { try {
atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => { atManager.on('permissionStateChange', tokenIDList, permissionList, (data) => {
console.debug("receive permission state change, data:" + JSON.stringify(data)); console.debug('receive permission state change, data:' + JSON.stringify(data));
}); });
} catch(err) { } catch(err) {
console.log(`catch err->${JSON.stringify(err)}`); console.log(`catch err->${JSON.stringify(err)}`);
...@@ -505,20 +505,20 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -505,20 +505,20 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. | | 12100001 | The parameter is invalid. The tokenIDs or permissionNames in the list are all invalid. |
| 12100004 | The interface is not used together with "on". | | 12100004 | The interface is not used together with 'on'. |
| 12100007 | Service is abnormal. | | 12100007 | Service is abnormal. |
| 12100008 | Out of memory. | | 12100008 | Out of memory. |
**Example** **Example**
```js ```js
import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; import {Permissions} from '@ohos.abilityAccessCtrl';
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100); let appInfo = bundleManager.getApplicationInfoSync('com.example.myapplication', 0, 100);
let tokenIDList: Array<number> = [appInfo.accessTokenId]; let tokenIDList: Array<number> = [appInfo.accessTokenId];
let permissionList: Array<Permissions> = ["ohos.permission.DISTRIBUTED_DATASYNC"]; let permissionList: Array<Permissions> = ['ohos.permission.DISTRIBUTED_DATASYNC'];
try { try {
atManager.off('permissionStateChange', tokenIDList, permissionList); atManager.off('permissionStateChange', tokenIDList, permissionList);
} catch(err) { } catch(err) {
...@@ -558,7 +558,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; ...@@ -558,7 +558,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => { promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`); console.log(`promise: data->${JSON.stringify(data)}`);
}); });
...@@ -599,10 +599,10 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -599,10 +599,10 @@ For details about the error codes, see [Application Access Control Error Codes](
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
try { try {
atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"], (err, data)=>{ atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA'], (err, data)=>{
console.info("data:" + JSON.stringify(data)); console.info('data:' + JSON.stringify(data));
console.info("data permissions:" + data.permissions); console.info('data permissions:' + data.permissions);
console.info("data authResults:" + data.authResults); console.info('data authResults:' + data.authResults);
}); });
} catch(err) { } catch(err) {
console.log(`catch err->${JSON.stringify(err)}`); console.log(`catch err->${JSON.stringify(err)}`);
...@@ -650,12 +650,12 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -650,12 +650,12 @@ For details about the error codes, see [Application Access Control Error Codes](
import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
try { try {
atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => { atManager.requestPermissionsFromUser(this.context, ['ohos.permission.CAMERA']).then((data) => {
console.info("data:" + JSON.stringify(data)); console.info('data:' + JSON.stringify(data));
console.info("data permissions:" + data.permissions); console.info('data permissions:' + data.permissions);
console.info("data authResults:" + data.authResults); console.info('data authResults:' + data.authResults);
}).catch((err) => { }).catch((err) => {
console.info("data:" + JSON.stringify(err)); console.info('data:' + JSON.stringify(err));
}) })
} catch(err) { } catch(err) {
console.log(`catch err->${JSON.stringify(err)}`); console.log(`catch err->${JSON.stringify(err)}`);
...@@ -694,7 +694,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; ...@@ -694,7 +694,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let promise = atManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let promise = atManager.verifyAccessToken(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
promise.then(data => { promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`); console.log(`promise: data->${JSON.stringify(data)}`);
}); });
...@@ -727,14 +727,14 @@ For details about the error codes, see [Application Access Control Error Codes]( ...@@ -727,14 +727,14 @@ For details about the error codes, see [Application Access Control Error Codes](
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The parameter is invalid. The tokenID is 0 or the permissionName exceeds 256 bytes. | | 12100001 | The parameter is invalid. The tokenID is 0, or the permissionName exceeds 256 bytes. |
**Example** **Example**
```js ```js
let atManager = abilityAccessCtrl.createAtManager(); let atManager = abilityAccessCtrl.createAtManager();
let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application. let tokenID = 0; // Use bundleManager.getApplicationInfo() to obtain the token ID for a system application, and use bundleManager.getBundleInfoForSelf() to obtain the token ID for a non-system application.
let data = atManager.checkAccessTokenSync(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); let data = atManager.checkAccessTokenSync(tokenID, 'ohos.permission.GRANT_SENSITIVE_PERMISSIONS');
console.log(`data->${JSON.stringify(data)}`); console.log(`data->${JSON.stringify(data)}`);
``` ```
......
...@@ -65,11 +65,11 @@ Creates an app account. This API uses an asynchronous callback to return the res ...@@ -65,11 +65,11 @@ Creates an app account. This API uses an asynchronous callback to return the res
```js ```js
try { try {
appAccountManager.createAccount("WangWu", (err) => { appAccountManager.createAccount('WangWu', (err) => {
console.log("createAccount err: " + JSON.stringify(err)); console.log('createAccount err: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("createAccount err: " + JSON.stringify(err)); console.log('createAccount err: ' + JSON.stringify(err));
} }
``` ```
...@@ -103,19 +103,19 @@ Creates an app account with custom data. This API uses an asynchronous callback ...@@ -103,19 +103,19 @@ Creates an app account with custom data. This API uses an asynchronous callback
```js ```js
let options = { let options = {
customData: { customData: {
"age": "10" 'age': '10'
} }
} }
try { try {
appAccountManager.createAccount("LiSi", options, (err) => { appAccountManager.createAccount('LiSi', options, (err) => {
if (err) { if (err) {
console.log("createAccount failed, error: " + JSON.stringify(err)); console.log('createAccount failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("createAccount successfully"); console.log('createAccount successfully');
} }
}); });
} catch(err) { } catch(err) {
console.log("createAccount exception: " + JSON.stringify(err)); console.log('createAccount exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -132,7 +132,7 @@ Creates an app account with custom data. This API uses a promise to return the r ...@@ -132,7 +132,7 @@ Creates an app account with custom data. This API uses a promise to return the r
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------------------------------------- | | --------- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the app account to create. | | name | string | Yes | Name of the app account to create. |
| options | [CreateAccountOptions](#createaccountoptions9) | No | Options for creating the app account. You can customize data based on service requirements, but do not add sensitive data (such as passwords and tokens). This parameter can be left empty.| | options | [CreateAccountOptions](#createaccountoptions9) | No | Options for creating the app account. You can customize data based on service requirements, but do not add sensitive data (such as passwords and tokens).<br>By default, no value is passed, which means no additional information needs to be added for the account.|
**Return value** **Return value**
...@@ -154,17 +154,17 @@ Creates an app account with custom data. This API uses a promise to return the r ...@@ -154,17 +154,17 @@ Creates an app account with custom data. This API uses a promise to return the r
```js ```js
let options = { let options = {
customData: { customData: {
"age": "10" 'age': '10'
} }
} }
try { try {
appAccountManager.createAccount("LiSi", options).then(() => { appAccountManager.createAccount('LiSi', options).then(() => {
console.log("createAccount successfully"); console.log('createAccount successfully');
}).catch((err) => { }).catch((err) => {
console.log("createAccount failed, error: " + JSON.stringify(err)); console.log('createAccount failed, error: ' + JSON.stringify(err));
}); });
} catch(err) { } catch(err) {
console.log("createAccount exception: " + JSON.stringify(err)); console.log('createAccount exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -198,8 +198,8 @@ Creates an app account implicitly based on the specified account owner. This API ...@@ -198,8 +198,8 @@ Creates an app account implicitly based on the specified account owner. This API
```js ```js
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("result: " + JSON.stringify(result)); console.log('result: ' + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -210,19 +210,19 @@ Creates an app account implicitly based on the specified account owner. This API ...@@ -210,19 +210,19 @@ Creates an app account implicitly based on the specified account owner. This API
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
try { try {
appAccountManager.createAccountImplicitly("com.example.accountjsdemo", { appAccountManager.createAccountImplicitly('com.example.accountjsdemo', {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
} catch (err) { } catch (err) {
console.log("createAccountImplicitly exception: " + JSON.stringify(err)); console.log('createAccountImplicitly exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -257,8 +257,8 @@ Creates an app account implicitly based on the specified account owner and optio ...@@ -257,8 +257,8 @@ Creates an app account implicitly based on the specified account owner and optio
```js ```js
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("result: " + JSON.stringify(result)); console.log('result: ' + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -269,23 +269,23 @@ Creates an app account implicitly based on the specified account owner and optio ...@@ -269,23 +269,23 @@ Creates an app account implicitly based on the specified account owner and optio
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
let options = { let options = {
authType: "getSocialData", authType: 'getSocialData',
requiredLabels: [ "student" ] requiredLabels: [ 'student' ]
}; };
try { try {
appAccountManager.createAccountImplicitly("com.example.accountjsdemo", options, { appAccountManager.createAccountImplicitly('com.example.accountjsdemo', options, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
} catch (err) { } catch (err) {
console.log("createAccountImplicitly exception: " + JSON.stringify(err)); console.log('createAccountImplicitly exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -316,15 +316,15 @@ Removes an app account. This API uses an asynchronous callback to return the res ...@@ -316,15 +316,15 @@ Removes an app account. This API uses an asynchronous callback to return the res
```js ```js
try { try {
appAccountManager.removeAccount("ZhaoLiu", (err) => { appAccountManager.removeAccount('ZhaoLiu', (err) => {
if (err) { if (err) {
console.log("removeAccount failed, error: " + JSON.stringify(err)); console.log('removeAccount failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("removeAccount successfully"); console.log('removeAccount successfully');
} }
}); });
} catch(err) { } catch(err) {
console.log("removeAccount exception: " + JSON.stringify(err)); console.log('removeAccount exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -360,13 +360,13 @@ Removes an app account. This API uses a promise to return the result. ...@@ -360,13 +360,13 @@ Removes an app account. This API uses a promise to return the result.
```js ```js
try { try {
appAccountManager.removeAccount("Lisi").then(() => { appAccountManager.removeAccount('Lisi').then(() => {
console.log("removeAccount successfully"); console.log('removeAccount successfully');
}).catch((err) => { }).catch((err) => {
console.log("removeAccount failed, error: " + JSON.stringify(err)); console.log('removeAccount failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("removeAccount exception: " + JSON.stringify(err)); console.log('removeAccount exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -400,15 +400,15 @@ Sets the access to the data of an account for an app. This API uses an asynchron ...@@ -400,15 +400,15 @@ Sets the access to the data of an account for an app. This API uses an asynchron
```js ```js
try { try {
appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true, (err) => { appAccountManager.setAppAccess('ZhangSan', 'com.example.accountjsdemo', true, (err) => {
if (err) { if (err) {
console.log("setAppAccess failed: " + JSON.stringify(err)); console.log('setAppAccess failed: ' + JSON.stringify(err));
} else { } else {
console.log("setAppAccess successfully"); console.log('setAppAccess successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("setAppAccess exception: " + JSON.stringify(err)); console.log('setAppAccess exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -447,13 +447,13 @@ Sets the access to the data of an account for an app. This API uses a promise to ...@@ -447,13 +447,13 @@ Sets the access to the data of an account for an app. This API uses a promise to
```js ```js
try { try {
appAccountManager.setAppAccess("ZhangSan", "com.example.accountjsdemo", true).then(() => { appAccountManager.setAppAccess('ZhangSan', 'com.example.accountjsdemo', true).then(() => {
console.log("setAppAccess successfully"); console.log('setAppAccess successfully');
}).catch((err) => { }).catch((err) => {
console.log("setAppAccess failed: " + JSON.stringify(err)); console.log('setAppAccess failed: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setAppAccess exception: " + JSON.stringify(err)); console.log('setAppAccess exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -485,15 +485,15 @@ Checks whether an app can access the data of an account. This API uses an asynch ...@@ -485,15 +485,15 @@ Checks whether an app can access the data of an account. This API uses an asynch
```js ```js
try { try {
appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo", (err, isAccessible) => { appAccountManager.checkAppAccess('ZhangSan', 'com.example.accountjsdemo', (err, isAccessible) => {
if (err) { if (err) {
console.log("checkAppAccess failed, error: " + JSON.stringify(err)); console.log('checkAppAccess failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("checkAppAccess successfully"); console.log('checkAppAccess successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("checkAppAccess exception: " + JSON.stringify(err)); console.log('checkAppAccess exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -530,13 +530,13 @@ Checks whether an app can access the data of an account. This API uses a promise ...@@ -530,13 +530,13 @@ Checks whether an app can access the data of an account. This API uses a promise
```js ```js
try { try {
appAccountManager.checkAppAccess("ZhangSan", "com.example.accountjsdemo").then((isAccessible) => { appAccountManager.checkAppAccess('ZhangSan', 'com.example.accountjsdemo').then((isAccessible) => {
console.log("checkAppAccess successfully, isAccessible: " + isAccessible); console.log('checkAppAccess successfully, isAccessible: ' + isAccessible);
}).catch((err) => { }).catch((err) => {
console.log("checkAppAccess failed, error: " + JSON.stringify(err)); console.log('checkAppAccess failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("checkAppAccess exception: " + JSON.stringify(err)); console.log('checkAppAccess exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -570,11 +570,11 @@ Sets data synchronization for an app account. This API uses an asynchronous call ...@@ -570,11 +570,11 @@ Sets data synchronization for an app account. This API uses an asynchronous call
```js ```js
try { try {
appAccountManager.setDataSyncEnabled("ZhangSan", true, (err) => { appAccountManager.setDataSyncEnabled('ZhangSan', true, (err) => {
console.log("setDataSyncEnabled err: " + JSON.stringify(err)); console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setDataSyncEnabled err: " + JSON.stringify(err)); console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
} }
``` ```
...@@ -613,13 +613,13 @@ Sets data synchronization for an app account. This API uses a promise to return ...@@ -613,13 +613,13 @@ Sets data synchronization for an app account. This API uses a promise to return
```js ```js
try { try {
appAccountManager .setDataSyncEnabled("ZhangSan", true).then(() => { appAccountManager .setDataSyncEnabled('ZhangSan', true).then(() => {
console.log('setDataSyncEnabled Success'); console.log('setDataSyncEnabled Success');
}).catch((err) => { }).catch((err) => {
console.log("setDataSyncEnabled err: " + JSON.stringify(err)); console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setDataSyncEnabled err: " + JSON.stringify(err)); console.log('setDataSyncEnabled err: ' + JSON.stringify(err));
} }
``` ```
...@@ -652,15 +652,15 @@ Checks whether data synchronization is enabled for an app account. This API uses ...@@ -652,15 +652,15 @@ Checks whether data synchronization is enabled for an app account. This API uses
```js ```js
try { try {
appAccountManager.checkDataSyncEnabled("ZhangSan", (err, isEnabled) => { appAccountManager.checkDataSyncEnabled('ZhangSan', (err, isEnabled) => {
if (err) { if (err) {
console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err)); console.log('checkDataSyncEnabled failed, err: ' + JSON.stringify(err));
} else { } else {
console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled); console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled);
} }
}); });
} catch (err) { } catch (err) {
console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); console.log('checkDataSyncEnabled err: ' + JSON.stringify(err));
} }
``` ```
...@@ -698,13 +698,13 @@ Checks whether data synchronization is enabled for an app account. This API uses ...@@ -698,13 +698,13 @@ Checks whether data synchronization is enabled for an app account. This API uses
```js ```js
try { try {
appAccountManager.checkDataSyncEnabled("ZhangSan").then((isEnabled) => { appAccountManager.checkDataSyncEnabled('ZhangSan').then((isEnabled) => {
console.log("checkDataSyncEnabled successfully, isEnabled: " + isEnabled); console.log('checkDataSyncEnabled successfully, isEnabled: ' + isEnabled);
}).catch((err) => { }).catch((err) => {
console.log("checkDataSyncEnabled failed, err: " + JSON.stringify(err)); console.log('checkDataSyncEnabled failed, err: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("checkDataSyncEnabled err: " + JSON.stringify(err)); console.log('checkDataSyncEnabled err: ' + JSON.stringify(err));
} }
``` ```
...@@ -737,15 +737,15 @@ Sets a credential for an app account. This API uses an asynchronous callback to ...@@ -737,15 +737,15 @@ Sets a credential for an app account. This API uses an asynchronous callback to
```js ```js
try { try {
appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx", (err) => { appAccountManager.setCredential('ZhangSan', 'PIN_SIX', 'xxxxxx', (err) => {
if (err) { if (err) {
console.log("setCredential failed, error: " + JSON.stringify(err)); console.log('setCredential failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("setCredential successfully"); console.log('setCredential successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("setCredential exception: " + JSON.stringify(err)); console.log('setCredential exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -783,13 +783,13 @@ Sets a credential for an app account. This API uses a promise to return the resu ...@@ -783,13 +783,13 @@ Sets a credential for an app account. This API uses a promise to return the resu
```js ```js
try { try {
appAccountManager.setCredential("ZhangSan", "PIN_SIX", "xxxxxx").then(() => { appAccountManager.setCredential('ZhangSan', 'PIN_SIX', 'xxxxxx').then(() => {
console.log("setCredential successfully"); console.log('setCredential successfully');
}).catch((err) => { }).catch((err) => {
console.log("setCredential failed, error: " + JSON.stringify(err)); console.log('setCredential failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setCredential exception: " + JSON.stringify(err)); console.log('setCredential exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -822,15 +822,15 @@ Obtains the credential of an app account. This API uses an asynchronous callback ...@@ -822,15 +822,15 @@ Obtains the credential of an app account. This API uses an asynchronous callback
```js ```js
try { try {
appAccountManager.getCredential("ZhangSan", "PIN_SIX", (err, result) => { appAccountManager.getCredential('ZhangSan', 'PIN_SIX', (err, result) => {
if (err) { if (err) {
console.log("getCredential failed, error: " + JSON.stringify(err)); console.log('getCredential failed, error: ' + JSON.stringify(err));
} else { } else {
console.log('getCredential successfully, result: ' + result); console.log('getCredential successfully, result: ' + result);
} }
}); });
} catch (err) { } catch (err) {
console.log("getCredential err: " + JSON.stringify(err)); console.log('getCredential err: ' + JSON.stringify(err));
} }
``` ```
...@@ -868,13 +868,13 @@ Obtains the credential of an app account. This API uses a promise to return the ...@@ -868,13 +868,13 @@ Obtains the credential of an app account. This API uses a promise to return the
```js ```js
try { try {
appAccountManager.getCredential("ZhangSan", "PIN_SIX").then((credential) => { appAccountManager.getCredential('ZhangSan', 'PIN_SIX').then((credential) => {
console.log("getCredential successfully, credential: " + credential); console.log('getCredential successfully, credential: ' + credential);
}).catch((err) => { }).catch((err) => {
console.log("getCredential failed, error: " + JSON.stringify(err)); console.log('getCredential failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getCredential exception: " + JSON.stringify(err)); console.log('getCredential exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -908,15 +908,15 @@ Sets custom data for an app account. This API uses an asynchronous callback to r ...@@ -908,15 +908,15 @@ Sets custom data for an app account. This API uses an asynchronous callback to r
```js ```js
try { try {
appAccountManager.setCustomData("ZhangSan", "age", "12", (err) => { appAccountManager.setCustomData('ZhangSan', 'age', '12', (err) => {
if (err) { if (err) {
console.log("setCustomData failed, error: " + JSON.stringify(err)); console.log('setCustomData failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("setCustomData successfully"); console.log('setCustomData successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("setCustomData exception: " + JSON.stringify(err)); console.log('setCustomData exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -955,13 +955,13 @@ Sets custom data for an app account. This API uses a promise to return the resul ...@@ -955,13 +955,13 @@ Sets custom data for an app account. This API uses a promise to return the resul
```js ```js
try { try {
appAccountManager.setCustomData("ZhangSan", "age", "12").then(() => { appAccountManager.setCustomData('ZhangSan', 'age', '12').then(() => {
console.log("setCustomData successfully"); console.log('setCustomData successfully');
}).catch((err) => { }).catch((err) => {
console.log("setCustomData failed, error: " + JSON.stringify(err)); console.log('setCustomData failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setCustomData exception: " + JSON.stringify(err)); console.log('setCustomData exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -994,15 +994,15 @@ Obtains the custom data of an app account based on the specified key. This API u ...@@ -994,15 +994,15 @@ Obtains the custom data of an app account based on the specified key. This API u
```js ```js
try { try {
appAccountManager.getCustomData("ZhangSan", "age", (err, data) => { appAccountManager.getCustomData('ZhangSan', 'age', (err, data) => {
if (err) { if (err) {
console.log('getCustomData failed, error: ' + err); console.log('getCustomData failed, error: ' + err);
} else { } else {
console.log("getCustomData successfully, data: " + data); console.log('getCustomData successfully, data: ' + data);
} }
}); });
} catch (err) { } catch (err) {
console.log("getCustomData exception: " + JSON.stringify(err)); console.log('getCustomData exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1040,13 +1040,13 @@ Obtains the custom data of an app account based on the specified key. This API u ...@@ -1040,13 +1040,13 @@ Obtains the custom data of an app account based on the specified key. This API u
```js ```js
try { try {
appAccountManager.getCustomData("ZhangSan", "age").then((data) => { appAccountManager.getCustomData('ZhangSan', 'age').then((data) => {
console.log("getCustomData successfully, data: " + data); console.log('getCustomData successfully, data: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getCustomData failed, error: " + JSON.stringify(err)); console.log('getCustomData failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getCustomData exception: " + JSON.stringify(err)); console.log('getCustomData exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1084,10 +1084,10 @@ Obtains the custom data of an app account based on the specified key. The API re ...@@ -1084,10 +1084,10 @@ Obtains the custom data of an app account based on the specified key. The API re
```js ```js
try { try {
let value = appAccountManager.getCustomDataSync("ZhangSan", "age"); let value = appAccountManager.getCustomDataSync('ZhangSan', 'age');
console.info("getCustomDataSync successfully, vaue:" + value); console.info('getCustomDataSync successfully, vaue: ' + value);
} catch (err) { } catch (err) {
console.error("getCustomDataSync failed, error: " + JSON.stringify(err)); console.error('getCustomDataSync failed, error: ' + JSON.stringify(err));
} }
``` ```
...@@ -1117,13 +1117,13 @@ Obtains information about all accessible app accounts. This API uses an asynchro ...@@ -1117,13 +1117,13 @@ Obtains information about all accessible app accounts. This API uses an asynchro
try { try {
appAccountManager.getAllAccounts((err, data) => { appAccountManager.getAllAccounts((err, data) => {
if (err) { if (err) {
console.debug("getAllAccounts failed, error:" + JSON.stringify(err)); console.debug('getAllAccounts failed, error: ' + JSON.stringify(err));
} else { } else {
console.debug("getAllAccounts successfully"); console.debug('getAllAccounts successfully');
} }
}); });
} catch (err) { } catch (err) {
console.debug("getAllAccounts exception: " + JSON.stringify(err)); console.debug('getAllAccounts exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1152,12 +1152,12 @@ Obtains information about all accessible app accounts. This API uses a promise t ...@@ -1152,12 +1152,12 @@ Obtains information about all accessible app accounts. This API uses a promise t
```js ```js
try { try {
appAccountManager.getAllAccounts().then((data) => { appAccountManager.getAllAccounts().then((data) => {
console.debug("getAllAccounts successfully"); console.debug('getAllAccounts successfully');
}).catch((err) => { }).catch((err) => {
console.debug("getAllAccounts failed, error:" + JSON.stringify(err)); console.debug('getAllAccounts failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.debug("getAllAccounts exception: " + JSON.stringify(err)); console.debug('getAllAccounts exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1188,15 +1188,15 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac ...@@ -1188,15 +1188,15 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac
```js ```js
try { try {
appAccountManager.getAccountsByOwner("com.example.accountjsdemo2", (err, data) => { appAccountManager.getAccountsByOwner('com.example.accountjsdemo2', (err, data) => {
if (err) { if (err) {
console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err)); console.debug('getAccountsByOwner failed, error:' + JSON.stringify(err));
} else { } else {
console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data)); console.debug('getAccountsByOwner successfully, data:' + JSON.stringify(data));
} }
}); });
} catch (err) { } catch (err) {
console.debug("getAccountsByOwner exception:" + JSON.stringify(err)); console.debug('getAccountsByOwner exception:' + JSON.stringify(err));
} }
``` ```
...@@ -1232,13 +1232,13 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac ...@@ -1232,13 +1232,13 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac
```js ```js
try { try {
appAccountManager.getAccountsByOwner("com.example.accountjsdemo2").then((data) => { appAccountManager.getAccountsByOwner('com.example.accountjsdemo2').then((data) => {
console.debug("getAccountsByOwner successfully, data:" + JSON.stringify(data)); console.debug('getAccountsByOwner successfully, data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.debug("getAccountsByOwner failed, error:" + JSON.stringify(err)); console.debug('getAccountsByOwner failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.debug("getAccountsByOwner exception:" + JSON.stringify(err)); console.debug('getAccountsByOwner exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1256,7 +1256,7 @@ Subscribes to account information changes of apps. ...@@ -1256,7 +1256,7 @@ Subscribes to account information changes of apps.
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | 'accountChange' | Yes | Event type to subscribe to. The value is **'accountChange'**. An event will be reported when the account information of the target app changes.| | type | 'accountChange' | Yes | Event type to subscribe to. The value is **'accountChange'**. An event will be reported when the account information of the target app changes.|
| owners | Array&lt;string&gt; | Yes | App bundle names of the account. | | owners | Array&lt;string&gt; | Yes | App bundle names of the account. |
| callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | Yes | Callback invoked to return a list of app accounts whose information is changed. | | callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | Yes | Callback registered to return the list of changed app accounts. |
**Error codes** **Error codes**
...@@ -1270,12 +1270,12 @@ Subscribes to account information changes of apps. ...@@ -1270,12 +1270,12 @@ Subscribes to account information changes of apps.
```js ```js
function changeOnCallback(data){ function changeOnCallback(data){
console.log("receive change data:" + JSON.stringify(data)); console.log('receive change data:' + JSON.stringify(data));
} }
try{ try{
appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback); appAccountManager.on('accountChange', ['com.example.actsaccounttest'], changeOnCallback);
} catch(err) { } catch(err) {
console.error("on accountChange failed, error:" + JSON.stringify(err)); console.error('on accountChange failed, error:' + JSON.stringify(err));
} }
``` ```
...@@ -1292,7 +1292,7 @@ Unsubscribes from account information changes. ...@@ -1292,7 +1292,7 @@ Unsubscribes from account information changes.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ---- | ------------ | | -------- | -------------------------------- | ---- | ------------ |
| type | 'accountChange' | Yes | Event type to unsubscribe from. The value is **'accountChange'**. | | type | 'accountChange' | Yes | Event type to unsubscribe from. The value is **'accountChange'**. |
| callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | No | Callback to unregister.| | callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | No | Callback to unregister. By default, no value is passed, which means to unregister all callbacks for the specified event.|
**Error codes** **Error codes**
...@@ -1305,18 +1305,18 @@ Unsubscribes from account information changes. ...@@ -1305,18 +1305,18 @@ Unsubscribes from account information changes.
```js ```js
function changeOnCallback(data) { function changeOnCallback(data) {
console.log("receive change data:" + JSON.stringify(data)); console.log('receive change data:' + JSON.stringify(data));
} }
try{ try{
appAccountManager.on("accountChange", ["com.example.actsaccounttest"], changeOnCallback); appAccountManager.on('accountChange', ['com.example.actsaccounttest'], changeOnCallback);
} catch(err) { } catch(err) {
console.error("on accountChange failed, error:" + JSON.stringify(err)); console.error('on accountChange failed, error:' + JSON.stringify(err));
} }
try{ try{
appAccountManager.off('accountChange', changeOnCallback); appAccountManager.off('accountChange', changeOnCallback);
} }
catch(err){ catch(err){
console.error("off accountChange failed, error:" + JSON.stringify(err)); console.error('off accountChange failed, error:' + JSON.stringify(err));
} }
``` ```
...@@ -1354,8 +1354,8 @@ Authenticates an app account. This API uses an asynchronous callback to return t ...@@ -1354,8 +1354,8 @@ Authenticates an app account. This API uses an asynchronous callback to return t
function onResultCallback(code, authResult) { function onResultCallback(code, authResult) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("authResult: " + JSON.stringify(authResult)); console.log('authResult: ' + JSON.stringify(authResult));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -1366,19 +1366,19 @@ Authenticates an app account. This API uses an asynchronous callback to return t ...@@ -1366,19 +1366,19 @@ Authenticates an app account. This API uses an asynchronous callback to return t
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
try { try {
appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", { appAccountManager.auth('LiSi', 'com.example.accountjsdemo', 'getSocialData', {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
} catch (err) { } catch (err) {
console.log("auth exception: " + JSON.stringify(err)); console.log('auth exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1417,8 +1417,8 @@ Authenticates an app account with customized options. This API uses an asynchron ...@@ -1417,8 +1417,8 @@ Authenticates an app account with customized options. This API uses an asynchron
function onResultCallback(code, authResult) { function onResultCallback(code, authResult) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("authResult: " + JSON.stringify(authResult)); console.log('authResult: ' + JSON.stringify(authResult));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -1429,22 +1429,22 @@ Authenticates an app account with customized options. This API uses an asynchron ...@@ -1429,22 +1429,22 @@ Authenticates an app account with customized options. This API uses an asynchron
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
let options = { let options = {
"password": "xxxx", 'password': 'xxxx',
}; };
try { try {
appAccountManager.auth("LiSi", "com.example.accountjsdemo", "getSocialData", options, { appAccountManager.auth('LiSi', 'com.example.accountjsdemo', 'getSocialData', options, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
} catch (err) { } catch (err) {
console.log("auth exception: " + JSON.stringify(err)); console.log('auth exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1478,15 +1478,15 @@ Obtains the authorization token of the specified authentication type for an app ...@@ -1478,15 +1478,15 @@ Obtains the authorization token of the specified authentication type for an app
```js ```js
try { try {
appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, token) => { appAccountManager.getAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', (err, token) => {
if (err) { if (err) {
console.log("getAuthToken failed, error: " + JSON.stringify(err)); console.log('getAuthToken failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("getAuthToken successfully, token: " + token); console.log('getAuthToken successfully, token: ' + token);
} }
}); });
} catch (err) { } catch (err) {
console.log("getAuthToken exception: " + JSON.stringify(err)); console.log('getAuthToken exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1525,13 +1525,13 @@ Obtains the authorization token of the specified authentication type for an app ...@@ -1525,13 +1525,13 @@ Obtains the authorization token of the specified authentication type for an app
```js ```js
try { try {
appAccountManager.getAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((token) => { appAccountManager.getAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData').then((token) => {
console.log("getAuthToken successfully, token: " + token); console.log('getAuthToken successfully, token: ' + token);
}).catch((err) => { }).catch((err) => {
console.log("getAuthToken failed, error: " + JSON.stringify(err)); console.log('getAuthToken failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getAuthToken exception: " + JSON.stringify(err)); console.log('getAuthToken exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1565,11 +1565,11 @@ Sets an authorization token of the specific authentication type for an app accou ...@@ -1565,11 +1565,11 @@ Sets an authorization token of the specific authentication type for an app accou
```js ```js
try { try {
appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx", (err) => { appAccountManager.setAuthToken('LiSi', 'getSocialData', 'xxxx', (err) => {
if (err) { if (err) {
console.log("setAuthToken failed, error: " + JSON.stringify(err)); console.log('setAuthToken failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("setAuthToken successfully"); console.log('setAuthToken successfully');
} }
}); });
} catch (err) { } catch (err) {
...@@ -1612,13 +1612,13 @@ Sets an authorization token of the specific authentication type for an app accou ...@@ -1612,13 +1612,13 @@ Sets an authorization token of the specific authentication type for an app accou
```js ```js
try { try {
appAccountManager.setAuthToken("LiSi", "getSocialData", "xxxx").then(() => { appAccountManager.setAuthToken('LiSi', 'getSocialData', 'xxxx').then(() => {
console.log("setAuthToken successfully"); console.log('setAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log("setAuthToken failed, error: " + JSON.stringify(err)); console.log('setAuthToken failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setAuthToken exception: " + JSON.stringify(err)); console.log('setAuthToken exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1653,11 +1653,11 @@ Deletes the authorization token of the specified authentication type for an app ...@@ -1653,11 +1653,11 @@ Deletes the authorization token of the specified authentication type for an app
```js ```js
try { try {
appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => { appAccountManager.deleteAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx', (err) => {
if (err) { if (err) {
console.log('deleteAuthToken failed, error: ' + JSON.stringify(err)); console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("deleteAuthToken successfully"); console.log('deleteAuthToken successfully');
} }
}); });
} catch (err) { } catch (err) {
...@@ -1701,8 +1701,8 @@ Deletes the authorization token of the specified authentication type for an app ...@@ -1701,8 +1701,8 @@ Deletes the authorization token of the specified authentication type for an app
```js ```js
try { try {
appAccountManager.deleteAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => { appAccountManager.deleteAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx').then(() => {
console.log("deleteAuthToken successfully"); console.log('deleteAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log('deleteAuthToken failed, error: ' + JSON.stringify(err)); console.log('deleteAuthToken failed, error: ' + JSON.stringify(err));
}); });
...@@ -1744,15 +1744,15 @@ Sets the visibility of an authorization token to an app. This API uses an asynch ...@@ -1744,15 +1744,15 @@ Sets the visibility of an authorization token to an app. This API uses an asynch
```js ```js
try { try {
appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => { appAccountManager.setAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true, (err) => {
if (err) { if (err) {
console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err)); console.log('setAuthTokenVisibility failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("setAuthTokenVisibility successfully"); console.log('setAuthTokenVisibility successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("setAuthTokenVisibility exception: " + JSON.stringify(err)); console.log('setAuthTokenVisibility exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1794,13 +1794,13 @@ Sets the visibility of an authorization token to an app. This API uses a promise ...@@ -1794,13 +1794,13 @@ Sets the visibility of an authorization token to an app. This API uses a promise
```js ```js
try { try {
appAccountManager.setAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => { appAccountManager.setAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true).then(() => {
console.log("setAuthTokenVisibility successfully"); console.log('setAuthTokenVisibility successfully');
}).catch((err) => { }).catch((err) => {
console.log("setAuthTokenVisibility failed, error: " + JSON.stringify(err)); console.log('setAuthTokenVisibility failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("setAuthTokenVisibility exception: " + JSON.stringify(err)); console.log('setAuthTokenVisibility exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1834,15 +1834,15 @@ Checks the visibility of an authorization token of the specified authentication ...@@ -1834,15 +1834,15 @@ Checks the visibility of an authorization token of the specified authentication
```js ```js
try { try {
appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, isVisible) => { appAccountManager.checkAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', (err, isVisible) => {
if (err) { if (err) {
console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err)); console.log('checkAuthTokenVisibility failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible); console.log('checkAuthTokenVisibility successfully, isVisible: ' + isVisible);
} }
}); });
} catch (err) { } catch (err) {
console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err)); console.log('checkAuthTokenVisibility exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1881,13 +1881,13 @@ Checks the visibility of an authorization token of the specified authentication ...@@ -1881,13 +1881,13 @@ Checks the visibility of an authorization token of the specified authentication
```js ```js
try { try {
appAccountManager.checkAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((isVisible) => { appAccountManager.checkAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo').then((isVisible) => {
console.log("checkAuthTokenVisibility successfully, isVisible: " + isVisible); console.log('checkAuthTokenVisibility successfully, isVisible: ' + isVisible);
}).catch((err) => { }).catch((err) => {
console.log("checkAuthTokenVisibility failed, error: " + JSON.stringify(err)); console.log('checkAuthTokenVisibility failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("checkAuthTokenVisibility exception: " + JSON.stringify(err)); console.log('checkAuthTokenVisibility exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1919,15 +1919,15 @@ Obtains all tokens visible to the invoker for an app account. This API uses an a ...@@ -1919,15 +1919,15 @@ Obtains all tokens visible to the invoker for an app account. This API uses an a
```js ```js
try { try {
appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo", (err, tokenArr) => { appAccountManager.getAllAuthTokens('LiSi', 'com.example.accountjsdemo', (err, tokenArr) => {
if (err) { if (err) {
console.log("getAllAuthTokens failed, error: " + JSON.stringify(err)); console.log('getAllAuthTokens failed, error: ' + JSON.stringify(err));
} else { } else {
console.log('getAllAuthTokens successfully, tokenArr: ' + tokenArr); console.log('getAllAuthTokens successfully, tokenArr: ' + tokenArr);
} }
}); });
} catch (err) { } catch (err) {
console.log("getAllAuthTokens exception: " + JSON.stringify(err)); console.log('getAllAuthTokens exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -1964,13 +1964,13 @@ Obtains all tokens visible to the invoker for an app account. This API uses a pr ...@@ -1964,13 +1964,13 @@ Obtains all tokens visible to the invoker for an app account. This API uses a pr
```js ```js
try { try {
appAccountManager.getAllAuthTokens("LiSi", "com.example.accountjsdemo").then((tokenArr) => { appAccountManager.getAllAuthTokens('LiSi', 'com.example.accountjsdemo').then((tokenArr) => {
console.log('getAllAuthTokens successfully, tokenArr: ' + JSON.stringify(tokenArr)); console.log('getAllAuthTokens successfully, tokenArr: ' + JSON.stringify(tokenArr));
}).catch((err) => { }).catch((err) => {
console.log("getAllAuthTokens failed, error: " + JSON.stringify(err)); console.log('getAllAuthTokens failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getAllAuthTokens exception: " + JSON.stringify(err)); console.log('getAllAuthTokens exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2003,11 +2003,11 @@ Obtains the authorization list of the specified authentication type for an app a ...@@ -2003,11 +2003,11 @@ Obtains the authorization list of the specified authentication type for an app a
```js ```js
try { try {
appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData", (err, authList) => { appAccountManager.getAuthList('LiSi', 'getSocialData', (err, authList) => {
if (err) { if (err) {
console.log("getAuthList failed, error: " + JSON.stringify(err)); console.log('getAuthList failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("getAuthList successfully, authList: " + authList); console.log('getAuthList successfully, authList: ' + authList);
} }
}); });
} catch (err) { } catch (err) {
...@@ -2049,13 +2049,13 @@ Obtains the authorization list of the specified authentication type for an app a ...@@ -2049,13 +2049,13 @@ Obtains the authorization list of the specified authentication type for an app a
```js ```js
try { try {
appAccountManager.getAuthList("com.example.accountjsdemo", "getSocialData").then((authList) => { appAccountManager.getAuthList('LiSi', 'getSocialData').then((authList) => {
console.log("getAuthList successfully, authList: " + authList); console.log('getAuthList successfully, authList: ' + authList);
}).catch((err) => { }).catch((err) => {
console.log("getAuthList failed, error: " + JSON.stringify(err)); console.log('getAuthList failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getAuthList exception: " + JSON.stringify(err)); console.log('getAuthList exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2063,7 +2063,7 @@ Obtains the authorization list of the specified authentication type for an app a ...@@ -2063,7 +2063,7 @@ Obtains the authorization list of the specified authentication type for an app a
getAuthCallback(sessionId: string, callback: AsyncCallback&lt;AuthCallback&gt;): void getAuthCallback(sessionId: string, callback: AsyncCallback&lt;AuthCallback&gt;): void
Obtains the authenticator callback for the authentication session. This API uses an asynchronous callback to return the result. Obtains the authenticator callback for an authentication session. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -2093,23 +2093,23 @@ Obtains the authenticator callback for the authentication session. This API uses ...@@ -2093,23 +2093,23 @@ Obtains the authenticator callback for the authentication session. This API uses
try { try {
appAccountManager.getAuthCallback(sessionId, (err, callback) => { appAccountManager.getAuthCallback(sessionId, (err, callback) => {
if (err != null) { if (err != null) {
console.log("getAuthCallback err: " + JSON.stringify(err)); console.log('getAuthCallback err: ' + JSON.stringify(err));
return; return;
} }
var result = { var result = {
accountInfo: { accountInfo: {
name: "Lisi", name: 'Lisi',
owner: "com.example.accountjsdemo", owner: 'com.example.accountjsdemo',
}, },
tokenInfo: { tokenInfo: {
token: "xxxxxx", token: 'xxxxxx',
authType: "getSocialData" authType: 'getSocialData'
} }
}; };
callback.onResult(0, result); callback.onResult(0, result);
}); });
} catch (err) { } catch (err) {
console.log("getAuthCallback exception: " + JSON.stringify(err)); console.log('getAuthCallback exception: ' + JSON.stringify(err));
} }
} }
} }
...@@ -2119,7 +2119,7 @@ Obtains the authenticator callback for the authentication session. This API uses ...@@ -2119,7 +2119,7 @@ Obtains the authenticator callback for the authentication session. This API uses
getAuthCallback(sessionId: string): Promise&lt;AuthCallback&gt; getAuthCallback(sessionId: string): Promise&lt;AuthCallback&gt;
Obtains the authenticator callback for the authentication session. This API uses a promise to return the result. Obtains the authenticator callback for an authentication session. This API uses a promise to return the result.
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -2155,20 +2155,20 @@ Obtains the authenticator callback for the authentication session. This API uses ...@@ -2155,20 +2155,20 @@ Obtains the authenticator callback for the authentication session. This API uses
appAccountManager.getAuthCallback(sessionId).then((callback) => { appAccountManager.getAuthCallback(sessionId).then((callback) => {
var result = { var result = {
accountInfo: { accountInfo: {
name: "Lisi", name: 'Lisi',
owner: "com.example.accountjsdemo", owner: 'com.example.accountjsdemo',
}, },
tokenInfo: { tokenInfo: {
token: "xxxxxx", token: 'xxxxxx',
authType: "getSocialData" authType: 'getSocialData'
} }
}; };
callback.onResult(0, result); callback.onResult(0, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthCallback err: " + JSON.stringify(err)); console.log('getAuthCallback err: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("getAuthCallback exception: " + JSON.stringify(err)); console.log('getAuthCallback exception: ' + JSON.stringify(err));
} }
} }
} }
...@@ -2201,15 +2201,15 @@ Obtains the authenticator information of an app. This API uses an asynchronous c ...@@ -2201,15 +2201,15 @@ Obtains the authenticator information of an app. This API uses an asynchronous c
```js ```js
try { try {
appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo", (err, info) => { appAccountManager.queryAuthenticatorInfo('com.example.accountjsdemo', (err, info) => {
if (err) { if (err) {
console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err)); console.log('queryAuthenticatorInfo failed, error: ' + JSON.stringify(err));
} else { } else {
console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info)); console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info));
} }
}); });
} catch (err) { } catch (err) {
console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err)); console.log('queryAuthenticatorInfo exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2245,13 +2245,13 @@ Obtains the authenticator information of an app. This API uses a promise to retu ...@@ -2245,13 +2245,13 @@ Obtains the authenticator information of an app. This API uses a promise to retu
```js ```js
try { try {
appAccountManager.queryAuthenticatorInfo("com.example.accountjsdemo").then((info) => { appAccountManager.queryAuthenticatorInfo('com.example.accountjsdemo').then((info) => {
console.log("queryAuthenticatorInfo successfully, info: " + JSON.stringify(info)); console.log('queryAuthenticatorInfo successfully, info: ' + JSON.stringify(info));
}).catch((err) => { }).catch((err) => {
console.log("queryAuthenticatorInfo failed, error: " + JSON.stringify(err)); console.log('queryAuthenticatorInfo failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("queryAuthenticatorInfo exception: " + JSON.stringify(err)); console.log('queryAuthenticatorInfo exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2286,17 +2286,17 @@ Checks whether an app account has specific labels. This API uses an asynchronous ...@@ -2286,17 +2286,17 @@ Checks whether an app account has specific labels. This API uses an asynchronous
**Example** **Example**
```js ```js
let labels = ["student"]; let labels = ['student'];
try { try {
appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels, (err, hasAllLabels) => { appAccountManager.checkAccountLabels('zhangsan', 'com.example.accountjsdemo', labels, (err, hasAllLabels) => {
if (err) { if (err) {
console.log("checkAccountLabels failed, error: " + JSON.stringify(err)); console.log('checkAccountLabels failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("checkAccountLabels successfully, hasAllLabels: " + hasAllLabels); console.log('checkAccountLabels successfully, hasAllLabels: ' + hasAllLabels);
} }
}); });
} catch (err) { } catch (err) {
console.log("checkAccountLabels exception: " + JSON.stringify(err)); console.log('checkAccountLabels exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2336,15 +2336,15 @@ Checks whether an app account has specific labels. This API uses a promise to re ...@@ -2336,15 +2336,15 @@ Checks whether an app account has specific labels. This API uses a promise to re
**Example** **Example**
```js ```js
let labels = ["student"]; let labels = ['student'];
try { try {
appAccountManager.checkAccountLabels("zhangsan", "com.example.accountjsdemo", labels).then((hasAllLabels) => { appAccountManager.checkAccountLabels('zhangsan', 'com.example.accountjsdemo', labels).then((hasAllLabels) => {
console.log('checkAccountLabels successfully: ' + hasAllLabels); console.log('checkAccountLabels successfully: ' + hasAllLabels);
}).catch((err) => { }).catch((err) => {
console.log("checkAccountLabels failed, error: " + JSON.stringify(err)); console.log('checkAccountLabels failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("checkAccountLabels exception: " + JSON.stringify(err)); console.log('checkAccountLabels exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2377,15 +2377,15 @@ Deletes the credential of the specified type from an app account. This API uses ...@@ -2377,15 +2377,15 @@ Deletes the credential of the specified type from an app account. This API uses
```js ```js
try { try {
appAccountManager.deleteCredential("zhangsan", "PIN_SIX", (err) => { appAccountManager.deleteCredential('zhangsan', 'PIN_SIX', (err) => {
if (err) { if (err) {
console.log("deleteCredential failed, error: " + JSON.stringify(err)); console.log('deleteCredential failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("deleteCredential successfully"); console.log('deleteCredential successfully');
} }
}); });
} catch (err) { } catch (err) {
console.log("deleteCredential exception: " + JSON.stringify(err)); console.log('deleteCredential exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2423,13 +2423,13 @@ Deletes the credential of the specified type from an app account. This API uses ...@@ -2423,13 +2423,13 @@ Deletes the credential of the specified type from an app account. This API uses
```js ```js
try { try {
appAccountManager.deleteCredential("zhangsan", "PIN_SIX").then(() => { appAccountManager.deleteCredential('zhangsan', 'PIN_SIX').then(() => {
console.log("deleteCredential successfully"); console.log('deleteCredential successfully');
}).catch((err) => { }).catch((err) => {
console.log("deleteCredential failed, error: " + JSON.stringify(err)); console.log('deleteCredential failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("deleteCredential exception: " + JSON.stringify(err)); console.log('deleteCredential exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2461,19 +2461,19 @@ Selects the accounts that can be accessed by the invoker based on the options. T ...@@ -2461,19 +2461,19 @@ Selects the accounts that can be accessed by the invoker based on the options. T
```js ```js
let options = { let options = {
allowedOwners: [ "com.example.accountjsdemo" ], allowedOwners: [ 'com.example.accountjsdemo' ],
requiredLabels: [ "student" ] requiredLabels: [ 'student' ]
}; };
try { try {
appAccountManager.selectAccountsByOptions(options, (err, accountArr) => { appAccountManager.selectAccountsByOptions(options, (err, accountArr) => {
if (err) { if (err) {
console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err)); console.log('selectAccountsByOptions failed, error: ' + JSON.stringify(err));
} else { } else {
console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr)); console.log('selectAccountsByOptions successfully, accountArr: ' + JSON.stringify(accountArr));
} }
}); });
} catch (err) { } catch (err) {
console.log("selectAccountsByOptions exception: " + JSON.stringify(err)); console.log('selectAccountsByOptions exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2510,16 +2510,16 @@ Selects the accounts that can be accessed by the invoker based on the options. T ...@@ -2510,16 +2510,16 @@ Selects the accounts that can be accessed by the invoker based on the options. T
```js ```js
let options = { let options = {
allowedOwners: ["com.example.accountjsdemo"] allowedOwners: ['com.example.accountjsdemo']
}; };
try { try {
appAccountManager.selectAccountsByOptions(options).then((accountArr) => { appAccountManager.selectAccountsByOptions(options).then((accountArr) => {
console.log("selectAccountsByOptions successfully, accountArr: " + JSON.stringify(accountArr)); console.log('selectAccountsByOptions successfully, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => { }).catch((err) => {
console.log("selectAccountsByOptions failed, error: " + JSON.stringify(err)); console.log('selectAccountsByOptions failed, error: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
console.log("selectAccountsByOptions exception: " + JSON.stringify(err)); console.log('selectAccountsByOptions exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -2554,17 +2554,17 @@ Verifies the credential of an app account. This API uses an asynchronous callbac ...@@ -2554,17 +2554,17 @@ Verifies the credential of an app account. This API uses an asynchronous callbac
```js ```js
try { try {
appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", { appAccountManager.verifyCredential('zhangsan', 'com.example.accountjsdemo', {
onResult: (resultCode, result) => { onResult: (resultCode, result) => {
console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); console.log('verifyCredential onResult, resultCode: ' + JSON.stringify(resultCode));
console.log("verifyCredential onResult, result:" + JSON.stringify(result)); console.log('verifyCredential onResult, result: ' + JSON.stringify(result));
}, },
onRequestRedirected: (request) => { onRequestRedirected: (request) => {
console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); console.log('verifyCredential onRequestRedirected, request: ' + JSON.stringify(request));
} }
}); });
} catch (err) { } catch (err) {
console.log("verifyCredential err: " + JSON.stringify(err)); console.log('verifyCredential err: ' + JSON.stringify(err));
} }
``` ```
...@@ -2600,21 +2600,21 @@ Verifies the user credential. This API uses an asynchronous callback to return t ...@@ -2600,21 +2600,21 @@ Verifies the user credential. This API uses an asynchronous callback to return t
```js ```js
let options = { let options = {
credentialType: "pin", credentialType: 'pin',
credential: "123456" credential: '123456'
}; };
try { try {
appAccountManager.verifyCredential("zhangsan", "com.example.accountjsdemo", options, { appAccountManager.verifyCredential('zhangsan', 'com.example.accountjsdemo', options, {
onResult: (resultCode, result) => { onResult: (resultCode, result) => {
console.log("verifyCredential onResult, resultCode:" + JSON.stringify(resultCode)); console.log('verifyCredential onResult, resultCode: ' + JSON.stringify(resultCode));
console.log("verifyCredential onResult, result:" + JSON.stringify(result)); console.log('verifyCredential onResult, result: ' + JSON.stringify(result));
}, },
onRequestRedirected: (request) => { onRequestRedirected: (request) => {
console.log("verifyCredential onRequestRedirected, request:" + JSON.stringify(request)); console.log('verifyCredential onRequestRedirected, request: ' + JSON.stringify(request));
} }
}); });
} catch (err) { } catch (err) {
console.log("verifyCredential err: " + JSON.stringify(err)); console.log('verifyCredential err: ' + JSON.stringify(err));
} }
``` ```
...@@ -2647,17 +2647,17 @@ Sets the authenticator attributes of an app. This API uses an asynchronous callb ...@@ -2647,17 +2647,17 @@ Sets the authenticator attributes of an app. This API uses an asynchronous callb
```js ```js
try { try {
appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", { appAccountManager.setAuthenticatorProperties('com.example.accountjsdemo', {
onResult: (resultCode, result) => { onResult: (resultCode, result) => {
console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); console.log('setAuthenticatorProperties onResult, resultCode: ' + JSON.stringify(resultCode));
console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); console.log('setAuthenticatorProperties onResult, result: ' + JSON.stringify(result));
}, },
onRequestRedirected: (request) => { onRequestRedirected: (request) => {
console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); console.log('setAuthenticatorProperties onRequestRedirected, request: ' + JSON.stringify(request));
} }
}); });
} catch (err) { } catch (err) {
console.log("setAuthenticatorProperties err: " + JSON.stringify(err)); console.log('setAuthenticatorProperties err: ' + JSON.stringify(err));
} }
``` ```
...@@ -2691,20 +2691,20 @@ Set authenticator properties. This API uses an asynchronous callback to return t ...@@ -2691,20 +2691,20 @@ Set authenticator properties. This API uses an asynchronous callback to return t
```js ```js
let options = { let options = {
properties: {"prop1": "value1"} properties: {'prop1': 'value1'}
}; };
try { try {
appAccountManager.setAuthenticatorProperties("com.example.accountjsdemo", options, { appAccountManager.setAuthenticatorProperties('com.example.accountjsdemo', options, {
onResult: (resultCode, result) => { onResult: (resultCode, result) => {
console.log("setAuthenticatorProperties onResult, resultCode:" + JSON.stringify(resultCode)); console.log('setAuthenticatorProperties onResult, resultCode: ' + JSON.stringify(resultCode));
console.log("setAuthenticatorProperties onResult, result:" + JSON.stringify(result)); console.log('setAuthenticatorProperties onResult, result: ' + JSON.stringify(result));
}, },
onRequestRedirected: (request) => { onRequestRedirected: (request) => {
console.log("setAuthenticatorProperties onRequestRedirected, request:" + JSON.stringify(request)); console.log('setAuthenticatorProperties onRequestRedirected, request: ' + JSON.stringify(request));
} }
}); });
} catch (err) { } catch (err) {
console.log("setAuthenticatorProperties err: " + JSON.stringify(err)); console.log('setAuthenticatorProperties err: ' + JSON.stringify(err));
} }
``` ```
...@@ -2732,8 +2732,8 @@ Adds an app account. This API uses an asynchronous callback to return the result ...@@ -2732,8 +2732,8 @@ Adds an app account. This API uses an asynchronous callback to return the result
**Example** **Example**
```js ```js
appAccountManager.addAccount("WangWu", (err) => { appAccountManager.addAccount('WangWu', (err) => {
console.log("addAccount err: " + JSON.stringify(err)); console.log('addAccount err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2744,7 +2744,6 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;) ...@@ -2744,7 +2744,6 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;)
Adds an app account name and additional information. This API uses an asynchronous callback to return the result. Adds an app account name and additional information. This API uses an asynchronous callback to return the result.
> **NOTE** > **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createAccount](#createaccount9-1). > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createAccount](#createaccount9-1).
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -2760,8 +2759,8 @@ Adds an app account name and additional information. This API uses an asynchrono ...@@ -2760,8 +2759,8 @@ Adds an app account name and additional information. This API uses an asynchrono
**Example** **Example**
```js ```js
appAccountManager.addAccount("LiSi", "token101", (err) => { appAccountManager.addAccount('LiSi', 'token101', (err) => {
console.log("addAccount err: " + JSON.stringify(err)); console.log('addAccount err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2771,8 +2770,7 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt; ...@@ -2771,8 +2770,7 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
Adds an app account name and additional information. This API uses an asynchronous callback to return the result. This API uses a promise to return the result. Adds an app account name and additional information. This API uses an asynchronous callback to return the result. This API uses a promise to return the result.
> **NOTE** > **NOTE**
>
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createAccount](#createaccount9-2). > This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createAccount](#createaccount9-2).
**System capability**: SystemCapability.Account.AppAccount **System capability**: SystemCapability.Account.AppAccount
...@@ -2782,7 +2780,7 @@ Adds an app account name and additional information. This API uses an asynchrono ...@@ -2782,7 +2780,7 @@ Adds an app account name and additional information. This API uses an asynchrono
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ---------------------------------------- | | --------- | ------ | ---- | ---------------------------------------- |
| name | string | Yes | Name of the target app account. | | name | string | Yes | Name of the target app account. |
| extraInfo | string | No | Additional information (information that can be converted to the string type). It cannot contain sensitive information, such as the app account password and token.| | extraInfo | string | No | Additional information (information that can be converted to the string type).<br>The additional information cannot be sensitive information (such as the password and token) of the app account.<br>By default, no value is passed, which means no additional information needs to be added for the account.|
**Return value** **Return value**
...@@ -2793,10 +2791,10 @@ Adds an app account name and additional information. This API uses an asynchrono ...@@ -2793,10 +2791,10 @@ Adds an app account name and additional information. This API uses an asynchrono
**Example** **Example**
```js ```js
appAccountManager.addAccount("LiSi", "token101").then(()=> { appAccountManager.addAccount('LiSi', 'token101').then(()=> {
console.log('addAccount Success'); console.log('addAccount Success');
}).catch((err) => { }).catch((err) => {
console.log("addAccount err: " + JSON.stringify(err)); console.log('addAccount err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2827,8 +2825,8 @@ Adds an app account implicitly based on the specified owner. This API uses an as ...@@ -2827,8 +2825,8 @@ Adds an app account implicitly based on the specified owner. This API uses an as
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("result: " + JSON.stringify(result)); console.log('result: ' + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -2839,13 +2837,13 @@ Adds an app account implicitly based on the specified owner. This API uses an as ...@@ -2839,13 +2837,13 @@ Adds an app account implicitly based on the specified owner. This API uses an as
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, { appAccountManager.addAccountImplicitly('com.example.accountjsdemo', 'getSocialData', {}, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
...@@ -2873,8 +2871,8 @@ Deletes an app account. This API uses an asynchronous callback to return the res ...@@ -2873,8 +2871,8 @@ Deletes an app account. This API uses an asynchronous callback to return the res
**Example** **Example**
```js ```js
appAccountManager.deleteAccount("ZhaoLiu", (err) => { appAccountManager.deleteAccount('ZhaoLiu', (err) => {
console.log("deleteAccount err: " + JSON.stringify(err)); console.log('deleteAccount err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2905,10 +2903,10 @@ Deletes an app account. This API uses a promise to return the result. ...@@ -2905,10 +2903,10 @@ Deletes an app account. This API uses a promise to return the result.
**Example** **Example**
```js ```js
appAccountManager.deleteAccount("ZhaoLiu").then(() => { appAccountManager.deleteAccount('ZhaoLiu').then(() => {
console.log('deleteAccount Success'); console.log('deleteAccount Success');
}).catch((err) => { }).catch((err) => {
console.log("deleteAccount err: " + JSON.stringify(err)); console.log('deleteAccount err: ' + JSON.stringify(err));
}); });
``` ```
### disableAppAccess<sup>(deprecated)</sup> ### disableAppAccess<sup>(deprecated)</sup>
...@@ -2934,8 +2932,8 @@ Disables an app account from accessing an app. This API uses an asynchronous cal ...@@ -2934,8 +2932,8 @@ Disables an app account from accessing an app. This API uses an asynchronous cal
**Example** **Example**
```js ```js
appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => { appAccountManager.disableAppAccess('ZhangSan', 'com.example.accountjsdemo', (err) => {
console.log("disableAppAccess err: " + JSON.stringify(err)); console.log('disableAppAccess err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2967,10 +2965,10 @@ Disables an app account from accessing an app. This API uses a promise to return ...@@ -2967,10 +2965,10 @@ Disables an app account from accessing an app. This API uses a promise to return
**Example** **Example**
```js ```js
appAccountManager.disableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => { appAccountManager.disableAppAccess('ZhangSan', 'com.example.accountjsdemo').then(() => {
console.log('disableAppAccess Success'); console.log('disableAppAccess Success');
}).catch((err) => { }).catch((err) => {
console.log("disableAppAccess err: " + JSON.stringify(err)); console.log('disableAppAccess err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -2997,8 +2995,8 @@ Enables an app account to access an app. This API uses an asynchronous callback ...@@ -2997,8 +2995,8 @@ Enables an app account to access an app. This API uses an asynchronous callback
**Example** **Example**
```js ```js
appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo", (err) => { appAccountManager.enableAppAccess('ZhangSan', 'com.example.accountjsdemo', (err) => {
console.log("enableAppAccess: " + JSON.stringify(err)); console.log('enableAppAccess: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3030,10 +3028,10 @@ Enables an app account to access an app. This API uses a promise to return the r ...@@ -3030,10 +3028,10 @@ Enables an app account to access an app. This API uses a promise to return the r
**Example** **Example**
```js ```js
appAccountManager.enableAppAccess("ZhangSan", "com.example.accountjsdemo").then(() => { appAccountManager.enableAppAccess('ZhangSan', 'com.example.accountjsdemo').then(() => {
console.log('enableAppAccess Success'); console.log('enableAppAccess Success');
}).catch((err) => { }).catch((err) => {
console.log("enableAppAccess err: " + JSON.stringify(err)); console.log('enableAppAccess err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3061,8 +3059,8 @@ Checks whether data synchronization is enabled for an app account. This API uses ...@@ -3061,8 +3059,8 @@ Checks whether data synchronization is enabled for an app account. This API uses
**Example** **Example**
```js ```js
appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { appAccountManager.checkAppAccountSyncEnable('ZhangSan', (err, result) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); console.log('checkAppAccountSyncEnable err: ' + JSON.stringify(err));
console.log('checkAppAccountSyncEnable result: ' + result); console.log('checkAppAccountSyncEnable result: ' + result);
}); });
``` ```
...@@ -3096,10 +3094,10 @@ Checks whether data synchronization is enabled for an app account. This API uses ...@@ -3096,10 +3094,10 @@ Checks whether data synchronization is enabled for an app account. This API uses
**Example** **Example**
```js ```js
appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { appAccountManager.checkAppAccountSyncEnable('ZhangSan').then((data) => {
console.log('checkAppAccountSyncEnable, result: ' + data); console.log('checkAppAccountSyncEnable, result: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); console.log('checkAppAccountSyncEnable err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3127,8 +3125,8 @@ Set credentials for an app account. This API uses an asynchronous callback to re ...@@ -3127,8 +3125,8 @@ Set credentials for an app account. This API uses an asynchronous callback to re
**Example** **Example**
```js ```js
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { appAccountManager.setAccountCredential('ZhangSan', 'credentialType001', 'credential001', (err) => {
console.log("setAccountCredential err: " + JSON.stringify(err)); console.log('setAccountCredential err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3161,10 +3159,10 @@ Set credentials for an app account. This API uses a promise to return the result ...@@ -3161,10 +3159,10 @@ Set credentials for an app account. This API uses a promise to return the result
**Example** **Example**
```js ```js
appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { appAccountManager.setAccountCredential('ZhangSan', 'credentialType001', 'credential001').then(() => {
console.log('setAccountCredential Success'); console.log('setAccountCredential Success');
}).catch((err) => { }).catch((err) => {
console.log("setAccountCredential err: " + JSON.stringify(err)); console.log('setAccountCredential err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3192,8 +3190,8 @@ Sets additional information for an app account. This API uses an asynchronous ca ...@@ -3192,8 +3190,8 @@ Sets additional information for an app account. This API uses an asynchronous ca
**Example** **Example**
```js ```js
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { appAccountManager.setAccountExtraInfo('ZhangSan', 'Tk002', (err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(err)); console.log('setAccountExtraInfo err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3226,10 +3224,10 @@ Sets additional information for an app account. This API uses a promise to retur ...@@ -3226,10 +3224,10 @@ Sets additional information for an app account. This API uses a promise to retur
**Example** **Example**
```js ```js
appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { appAccountManager.setAccountExtraInfo('ZhangSan', 'Tk002').then(() => {
console.log('setAccountExtraInfo Success'); console.log('setAccountExtraInfo Success');
}).catch((err) => { }).catch((err) => {
console.log("setAccountExtraInfo err: " + JSON.stringify(err)); console.log('setAccountExtraInfo err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3258,8 +3256,8 @@ Sets data synchronization for an app account. This API uses an asynchronous call ...@@ -3258,8 +3256,8 @@ Sets data synchronization for an app account. This API uses an asynchronous call
**Example** **Example**
```js ```js
appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { appAccountManager.setAppAccountSyncEnable('ZhangSan', true, (err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); console.log('setAppAccountSyncEnable err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3293,10 +3291,10 @@ Sets data synchronization for an app account. This API uses a promise to return ...@@ -3293,10 +3291,10 @@ Sets data synchronization for an app account. This API uses a promise to return
**Example** **Example**
```js ```js
appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { appAccountManager .setAppAccountSyncEnable('ZhangSan', true).then(() => {
console.log('setAppAccountSyncEnable Success'); console.log('setAppAccountSyncEnable Success');
}).catch((err) => { }).catch((err) => {
console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); console.log('setAppAccountSyncEnable err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3325,8 +3323,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca ...@@ -3325,8 +3323,8 @@ Sets data to be associated with an app account. This API uses an asynchronous ca
**Example** **Example**
```js ```js
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001", (err) => { appAccountManager.setAssociatedData('ZhangSan', 'k001', 'v001', (err) => {
console.log("setAssociatedData err: " + JSON.stringify(err)); console.log('setAssociatedData err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3360,10 +3358,10 @@ Sets data to be associated with an app account. This API uses a promise to retur ...@@ -3360,10 +3358,10 @@ Sets data to be associated with an app account. This API uses a promise to retur
**Example** **Example**
```js ```js
appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { appAccountManager.setAssociatedData('ZhangSan', 'k001', 'v001').then(() => {
console.log('setAssociatedData Success'); console.log('setAssociatedData Success');
}).catch((err) => { }).catch((err) => {
console.log("setAssociatedData err: " + JSON.stringify(err)); console.log('setAssociatedData err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3391,8 +3389,8 @@ Obtains information about all accessible app accounts. This API uses an asynchro ...@@ -3391,8 +3389,8 @@ Obtains information about all accessible app accounts. This API uses an asynchro
```js ```js
appAccountManager.getAllAccessibleAccounts((err, data)=>{ appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); console.debug('getAllAccessibleAccounts err: ' + JSON.stringify(err));
console.debug("getAllAccessibleAccounts data:" + JSON.stringify(data)); console.debug('getAllAccessibleAccounts data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -3422,7 +3420,7 @@ Obtains information about all accessible app accounts. This API uses a promise t ...@@ -3422,7 +3420,7 @@ Obtains information about all accessible app accounts. This API uses a promise t
appAccountManager.getAllAccessibleAccounts().then((data) => { appAccountManager.getAllAccessibleAccounts().then((data) => {
console.log('getAllAccessibleAccounts: ' + data); console.log('getAllAccessibleAccounts: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getAllAccessibleAccounts err: " + JSON.stringify(err)); console.log('getAllAccessibleAccounts err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3450,10 +3448,10 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac ...@@ -3450,10 +3448,10 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac
**Example** **Example**
```js ```js
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = 'com.example.actsgetallaaccounts';
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("getAllAccounts err:" + JSON.stringify(err)); console.debug('getAllAccounts err: ' + JSON.stringify(err));
console.debug("getAllAccounts data:" + JSON.stringify(data)); console.debug('getAllAccounts data:' + JSON.stringify(data));
}); });
``` ```
...@@ -3486,11 +3484,11 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac ...@@ -3486,11 +3484,11 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac
**Example** **Example**
```js ```js
const selfBundle = "com.example.actsgetallaaccounts"; const selfBundle = 'com.example.actsgetallaaccounts';
appAccountManager.getAllAccounts(selfBundle).then((data) => { appAccountManager.getAllAccounts(selfBundle).then((data) => {
console.log('getAllAccounts: ' + data); console.log('getAllAccounts: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getAllAccounts err: " + JSON.stringify(err)); console.log('getAllAccounts err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3517,8 +3515,8 @@ Obtains the credential of an app account. This API uses an asynchronous callback ...@@ -3517,8 +3515,8 @@ Obtains the credential of an app account. This API uses an asynchronous callback
**Example** **Example**
```js ```js
appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { appAccountManager.getAccountCredential('ZhangSan', 'credentialType001', (err, result) => {
console.log("getAccountCredential err: " + JSON.stringify(err)); console.log('getAccountCredential err: ' + JSON.stringify(err));
console.log('getAccountCredential result: ' + result); console.log('getAccountCredential result: ' + result);
}); });
``` ```
...@@ -3551,10 +3549,10 @@ Obtains the credential of an app account. This API uses a promise to return the ...@@ -3551,10 +3549,10 @@ Obtains the credential of an app account. This API uses a promise to return the
**Example** **Example**
```js ```js
appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { appAccountManager.getAccountCredential('ZhangSan', 'credentialType001').then((data) => {
console.log('getAccountCredential, result: ' + data); console.log('getAccountCredential, result: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getAccountCredential err: " + JSON.stringify(err)); console.log('getAccountCredential err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3580,8 +3578,8 @@ Obtains additional information of an app account. Additional information refers ...@@ -3580,8 +3578,8 @@ Obtains additional information of an app account. Additional information refers
**Example** **Example**
```js ```js
appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { appAccountManager.getAccountExtraInfo('ZhangSan', (err, result) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err)); console.log('getAccountExtraInfo err: ' + JSON.stringify(err));
console.log('getAccountExtraInfo result: ' + result); console.log('getAccountExtraInfo result: ' + result);
}); });
``` ```
...@@ -3613,10 +3611,10 @@ Obtains additional information of an app account. Additional information refers ...@@ -3613,10 +3611,10 @@ Obtains additional information of an app account. Additional information refers
**Example** **Example**
```js ```js
appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { appAccountManager.getAccountExtraInfo('ZhangSan').then((data) => {
console.log('getAccountExtraInfo, result: ' + data); console.log('getAccountExtraInfo, result: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getAccountExtraInfo err: " + JSON.stringify(err)); console.log('getAccountExtraInfo err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3643,8 +3641,8 @@ Obtains data associated with an app account. This API uses an asynchronous callb ...@@ -3643,8 +3641,8 @@ Obtains data associated with an app account. This API uses an asynchronous callb
**Example** **Example**
```js ```js
appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { appAccountManager.getAssociatedData('ZhangSan', 'k001', (err, result) => {
console.log("getAssociatedData err: " + JSON.stringify(err)); console.log('getAssociatedData err: ' + JSON.stringify(err));
console.log('getAssociatedData result: ' + result); console.log('getAssociatedData result: ' + result);
}); });
``` ```
...@@ -3677,10 +3675,10 @@ Obtains data associated with an app account. This API uses a promise to return t ...@@ -3677,10 +3675,10 @@ Obtains data associated with an app account. This API uses a promise to return t
**Example** **Example**
```js ```js
appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { appAccountManager.getAssociatedData('ZhangSan', 'k001').then((data) => {
console.log('getAssociatedData: ' + data); console.log('getAssociatedData: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getAssociatedData err: " + JSON.stringify(err)); console.log('getAssociatedData err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3702,19 +3700,19 @@ Subscribes to account information changes of apps. ...@@ -3702,19 +3700,19 @@ Subscribes to account information changes of apps.
| -------- | ---------------------------------------- | ---- | ------------------------------ | | -------- | ---------------------------------------- | ---- | ------------------------------ |
| type | 'change' | Yes | Event type to subscribe to. The value is **'change'**. An event will be reported when the account information changes.| | type | 'change' | Yes | Event type to subscribe to. The value is **'change'**. An event will be reported when the account information changes.|
| owners | Array&lt;string&gt; | Yes | App bundle names of the account. | | owners | Array&lt;string&gt; | Yes | App bundle names of the account. |
| callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | Yes | Callback invoked to return the account changes. | | callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | Yes | Callback registered to return the list of changed app accounts. |
**Example** **Example**
```js ```js
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug('receive change data:' + JSON.stringify(data));
} }
try{ try{
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); appAccountManager.on('change', ['com.example.actsaccounttest'], changeOnCallback);
} }
catch(err){ catch(err){
console.error("on accountOnOffDemo err:" + JSON.stringify(err)); console.error('on accountOnOffDemo err:' + JSON.stringify(err));
} }
``` ```
...@@ -3735,22 +3733,22 @@ Unsubscribes from account information changes. ...@@ -3735,22 +3733,22 @@ Unsubscribes from account information changes.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------------------- | ---- | ------------ | | -------- | -------------------------------- | ---- | ------------ |
| type | 'change' | Yes | Event type to unsubscribe from. The value is **'change'**, which indicates the account change event. | | type | 'change' | Yes | Event type to unsubscribe from. The value is **'change'**, which indicates the account change event. |
| callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | No | Callback to unregister.| | callback | Callback&lt;Array&lt;[AppAccountInfo](#appaccountinfo)&gt;&gt; | No | Callback to unregister. By default, no value is passed, which means to unregister all callbacks for the specified event.|
**Example** **Example**
```js ```js
function changeOnCallback(data){ function changeOnCallback(data){
console.debug("receive change data:" + JSON.stringify(data)); console.debug('receive change data: ' + JSON.stringify(data));
appAccountManager.off('change', function(){ appAccountManager.off('change', function(){
console.debug("off finish"); console.debug('off finish');
}) })
} }
try{ try{
appAccountManager.on('change', ["com.example.actsaccounttest"], changeOnCallback); appAccountManager.on('change', ['com.example.actsaccounttest'], changeOnCallback);
} }
catch(err){ catch(err){
console.error("on accountOnOffDemo err:" + JSON.stringify(err)); console.error('on accountOnOffDemo err: ' + JSON.stringify(err));
} }
``` ```
...@@ -3780,8 +3778,8 @@ Authenticates an app account with customized options. This API uses an asynchron ...@@ -3780,8 +3778,8 @@ Authenticates an app account with customized options. This API uses an asynchron
```js ```js
function onResultCallback(code, result) { function onResultCallback(code, result) {
console.log("resultCode: " + code); console.log('resultCode: ' + code);
console.log("result: " + JSON.stringify(result)); console.log('result: ' + JSON.stringify(result));
} }
function onRequestRedirectedCallback(request) { function onRequestRedirectedCallback(request) {
...@@ -3792,13 +3790,13 @@ Authenticates an app account with customized options. This API uses an asynchron ...@@ -3792,13 +3790,13 @@ Authenticates an app account with customized options. This API uses an asynchron
entities: ['entity.system.default'], entities: ['entity.system.default'],
} }
this.context.startAbility(wantInfo).then(() => { this.context.startAbility(wantInfo).then(() => {
console.log("startAbility successfully"); console.log('startAbility successfully');
}).catch((err) => { }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err)); console.log('startAbility err: ' + JSON.stringify(err));
}) })
} }
appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, { appAccountManager.authenticate('LiSi', 'com.example.accountjsdemo', 'getSocialData', {}, {
onResult: onResultCallback, onResult: onResultCallback,
onRequestRedirected: onRequestRedirectedCallback onRequestRedirected: onRequestRedirectedCallback
}); });
...@@ -3828,7 +3826,7 @@ Obtains the authorization token of the specified authentication type for an app ...@@ -3828,7 +3826,7 @@ Obtains the authorization token of the specified authentication type for an app
**Example** **Example**
```js ```js
appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", (err, data) => { appAccountManager.getOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', (err, data) => {
console.log('getOAuthToken err: ' + JSON.stringify(err)); console.log('getOAuthToken err: ' + JSON.stringify(err));
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
}); });
...@@ -3863,10 +3861,10 @@ Obtains the authorization token of the specified authentication type for an app ...@@ -3863,10 +3861,10 @@ Obtains the authorization token of the specified authentication type for an app
**Example** **Example**
```js ```js
appAccountManager.getOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData").then((data) => { appAccountManager.getOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData').then((data) => {
console.log('getOAuthToken token: ' + data); console.log('getOAuthToken token: ' + data);
}).catch((err) => { }).catch((err) => {
console.log("getOAuthToken err: " + JSON.stringify(err)); console.log('getOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3894,7 +3892,7 @@ Sets an authorization token of the specific authentication type for an app accou ...@@ -3894,7 +3892,7 @@ Sets an authorization token of the specific authentication type for an app accou
**Example** **Example**
```js ```js
appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx", (err) => { appAccountManager.setOAuthToken('LiSi', 'getSocialData', 'xxxx', (err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err)); console.log('setOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3928,7 +3926,7 @@ Sets an authorization token of the specific authentication type for an app accou ...@@ -3928,7 +3926,7 @@ Sets an authorization token of the specific authentication type for an app accou
**Example** **Example**
```js ```js
appAccountManager.setOAuthToken("LiSi", "getSocialData", "xxxx").then(() => { appAccountManager.setOAuthToken('LiSi', 'getSocialData', 'xxxx').then(() => {
console.log('setOAuthToken successfully'); console.log('setOAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log('setOAuthToken err: ' + JSON.stringify(err)); console.log('setOAuthToken err: ' + JSON.stringify(err));
...@@ -3960,7 +3958,7 @@ Deletes the authorization token of the specified authentication type for an app ...@@ -3960,7 +3958,7 @@ Deletes the authorization token of the specified authentication type for an app
**Example** **Example**
```js ```js
appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx", (err) => { appAccountManager.deleteOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx', (err) => {
console.log('deleteOAuthToken err: ' + JSON.stringify(err)); console.log('deleteOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -3995,10 +3993,10 @@ Deletes the authorization token of the specified authentication type for an app ...@@ -3995,10 +3993,10 @@ Deletes the authorization token of the specified authentication type for an app
**Example** **Example**
```js ```js
appAccountManager.deleteOAuthToken("LiSi", "com.example.accountjsdemo", "getSocialData", "xxxxx").then(() => { appAccountManager.deleteOAuthToken('LiSi', 'com.example.accountjsdemo', 'getSocialData', 'xxxxx').then(() => {
console.log('deleteOAuthToken successfully'); console.log('deleteOAuthToken successfully');
}).catch((err) => { }).catch((err) => {
console.log("deleteOAuthToken err: " + JSON.stringify(err)); console.log('deleteOAuthToken err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4027,7 +4025,7 @@ Sets the visibility of an authorization token to an app. This API uses an asynch ...@@ -4027,7 +4025,7 @@ Sets the visibility of an authorization token to an app. This API uses an asynch
**Example** **Example**
```js ```js
appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true, (err) => { appAccountManager.setOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true, (err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4062,7 +4060,7 @@ Sets the visibility of an authorization token to an app. This API uses a promise ...@@ -4062,7 +4060,7 @@ Sets the visibility of an authorization token to an app. This API uses a promise
**Example** **Example**
```js ```js
appAccountManager.setOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", true).then(() => { appAccountManager.setOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', true).then(() => {
console.log('setOAuthTokenVisibility successfully'); console.log('setOAuthTokenVisibility successfully');
}).catch((err) => { }).catch((err) => {
console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -4093,7 +4091,7 @@ Checks the visibility of an authorization token of the specified authentication ...@@ -4093,7 +4091,7 @@ Checks the visibility of an authorization token of the specified authentication
**Example** **Example**
```js ```js
appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo", (err, data) => { appAccountManager.checkOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo', (err, data) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
}); });
...@@ -4128,7 +4126,7 @@ Checks the visibility of an authorization token of the specified authentication ...@@ -4128,7 +4126,7 @@ Checks the visibility of an authorization token of the specified authentication
**Example** **Example**
```js ```js
appAccountManager.checkOAuthTokenVisibility("LiSi", "getSocialData", "com.example.accountjsdemo").then((data) => { appAccountManager.checkOAuthTokenVisibility('LiSi', 'getSocialData', 'com.example.accountjsdemo').then((data) => {
console.log('checkOAuthTokenVisibility isVisible: ' + data); console.log('checkOAuthTokenVisibility isVisible: ' + data);
}).catch((err) => { }).catch((err) => {
console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
...@@ -4158,8 +4156,8 @@ Obtains all tokens visible to the invoker for an app account. This API uses an a ...@@ -4158,8 +4156,8 @@ Obtains all tokens visible to the invoker for an app account. This API uses an a
**Example** **Example**
```js ```js
appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo", (err, data) => { appAccountManager.getAllOAuthTokens('LiSi', 'com.example.accountjsdemo', (err, data) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); console.log('getAllOAuthTokens err: ' + JSON.stringify(err));
console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -4192,10 +4190,10 @@ Obtains all tokens visible to the invoker for an app account. This API uses a pr ...@@ -4192,10 +4190,10 @@ Obtains all tokens visible to the invoker for an app account. This API uses a pr
**Example** **Example**
```js ```js
appAccountManager.getAllOAuthTokens("LiSi", "com.example.accountjsdemo").then((data) => { appAccountManager.getAllOAuthTokens('LiSi', 'com.example.accountjsdemo').then((data) => {
console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getAllOAuthTokens err: " + JSON.stringify(err)); console.log('getAllOAuthTokens err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4222,7 +4220,7 @@ Obtains the authorization list of the specified authentication type for an app a ...@@ -4222,7 +4220,7 @@ Obtains the authorization list of the specified authentication type for an app a
**Example** **Example**
```js ```js
appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData", (err, data) => { appAccountManager.getOAuthList('LiSi', 'getSocialData', (err, data) => {
console.log('getOAuthList err: ' + JSON.stringify(err)); console.log('getOAuthList err: ' + JSON.stringify(err));
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
}); });
...@@ -4256,10 +4254,10 @@ Obtains the authorization list of the specified authentication type for an app a ...@@ -4256,10 +4254,10 @@ Obtains the authorization list of the specified authentication type for an app a
**Example** **Example**
```js ```js
appAccountManager.getOAuthList("com.example.accountjsdemo", "getSocialData").then((data) => { appAccountManager.getOAuthList('LiSi', 'getSocialData').then((data) => {
console.log('getOAuthList data: ' + JSON.stringify(data)); console.log('getOAuthList data: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getOAuthList err: " + JSON.stringify(err)); console.log('getOAuthList err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4292,13 +4290,13 @@ Obtains the authenticator callback for an authentication session. This API uses ...@@ -4292,13 +4290,13 @@ Obtains the authenticator callback for an authentication session. This API uses
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => { appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
if (err.code != account_appAccount.ResultCode.SUCCESS) { if (err.code != account_appAccount.ResultCode.SUCCESS) {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
return; return;
} }
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
[account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}); });
} }
...@@ -4338,13 +4336,13 @@ Obtains the authenticator callback for an authentication session. This API uses ...@@ -4338,13 +4336,13 @@ Obtains the authenticator callback for an authentication session. This API uses
onCreate(want, param) { onCreate(want, param) {
var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID];
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
[account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
}); });
} }
} }
...@@ -4372,8 +4370,8 @@ Obtains the authenticator information of an app. This API uses an asynchronous c ...@@ -4372,8 +4370,8 @@ Obtains the authenticator information of an app. This API uses an asynchronous c
**Example** **Example**
```js ```js
appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo", (err, data) => { appAccountManager.getAuthenticatorInfo('com.example.accountjsdemo', (err, data) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); console.log('getAuthenticatorInfo err: ' + JSON.stringify(err));
console.log('getAuthenticatorInfo data: ' + JSON.stringify(data)); console.log('getAuthenticatorInfo data: ' + JSON.stringify(data));
}); });
``` ```
...@@ -4405,10 +4403,10 @@ Obtains the authenticator information of an app. This API uses a promise to retu ...@@ -4405,10 +4403,10 @@ Obtains the authenticator information of an app. This API uses a promise to retu
**Example** **Example**
```js ```js
appAccountManager.getAuthenticatorInfo("com.example.accountjsdemo").then((data) => { appAccountManager.getAuthenticatorInfo('com.example.accountjsdemo').then((data) => {
console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); console.log('getAuthenticatorInfo err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4433,7 +4431,7 @@ Defines authorization token information. ...@@ -4433,7 +4431,7 @@ Defines authorization token information.
| -------------------- | -------------- | ----- | ---------------- | | -------------------- | -------------- | ----- | ---------------- |
| authType<sup>9+</sup> | string | Yes | Authentication type. | | authType<sup>9+</sup> | string | Yes | Authentication type. |
| token<sup>9+</sup> | string | Yes | Value of the authorization token. | | token<sup>9+</sup> | string | Yes | Value of the authorization token. |
| account<sup>9+</sup> | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.| | account<sup>9+</sup> | [AppAccountInfo](#appaccountinfo) | No | Information about the account to which the token belongs. By default, no value is passed.|
## OAuthTokenInfo<sup>(deprecated)</sup> ## OAuthTokenInfo<sup>(deprecated)</sup>
...@@ -4449,7 +4447,7 @@ Defines authorization token information. ...@@ -4449,7 +4447,7 @@ Defines authorization token information.
| -------------------- | -------------- | ----- | ---------------- | | -------------------- | -------------- | ----- | ---------------- |
| authType | string | Yes | Authentication type. | | authType | string | Yes | Authentication type. |
| token | string | Yes | Value of the authorization token. | | token | string | Yes | Value of the authorization token. |
| account<sup>9+</sup> | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.| | account<sup>9+</sup> | [AppAccountInfo](#appaccountinfo) | No | Information about the account to which the token belongs. By default, no value is passed.|
## AuthenticatorInfo<sup>8+</sup> ## AuthenticatorInfo<sup>8+</sup>
...@@ -4471,8 +4469,8 @@ Defines the authentication result. ...@@ -4471,8 +4469,8 @@ Defines the authentication result.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- | | ------- | ------ | ---- | ---------- |
| account | [AppAccountInfo](#appaccountinfo) | No | Account information of the authorization token.| | account | [AppAccountInfo](#appaccountinfo) | No | Information about the account to which the token belongs. By default, no value is passed.|
| tokenInfo | [AuthTokenInfo](#authtokeninfo9) | No | Token information. | | tokenInfo | [AuthTokenInfo](#authtokeninfo9) | No | Token information. By default, no value is passed. |
## CreateAccountOptions<sup>9+</sup> ## CreateAccountOptions<sup>9+</sup>
...@@ -4482,7 +4480,7 @@ Defines the options for creating an app account. ...@@ -4482,7 +4480,7 @@ Defines the options for creating an app account.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- | | ------- | ------ | ---- | ---------- |
| customData | {[key: string]: string} | No | Custom data.| | customData | {[key: string]: string} | No | Custom data. By default, no value is passed.|
## CreateAccountImplicitlyOptions<sup>9+</sup> ## CreateAccountImplicitlyOptions<sup>9+</sup>
...@@ -4492,9 +4490,9 @@ Defines the options for implicitly creating an app account. ...@@ -4492,9 +4490,9 @@ Defines the options for implicitly creating an app account.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------- | | ------- | ------ | ---- | ---------- |
| requiredLabels | Array&lt;string&gt; | No | Labels required.| | requiredLabels | Array&lt;string&gt; | No | Required labels. By default, no value is passed.|
| authType | string | No | Authentication type.| | authType | string | No | Authentication type. By default, no value is passed.|
| parameters | {[key: string]: Object} | No | Customized parameters.| | parameters | {[key: string]: Object} | No | Custom parameter object. By default, no value is passed.|
## SelectAccountsOptions<sup>9+</sup> ## SelectAccountsOptions<sup>9+</sup>
Defines the options for selecting accounts. Defines the options for selecting accounts.
...@@ -4503,9 +4501,9 @@ Defines the options for selecting accounts. ...@@ -4503,9 +4501,9 @@ Defines the options for selecting accounts.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------------- | --------------------------- | ----- | ------------------- | | --------------- | --------------------------- | ----- | ------------------- |
| allowedAccounts | Array&lt;[AppAccountInfo](#appaccountinfo)&gt; | No | Allowed accounts. | | allowedAccounts | Array&lt;[AppAccountInfo](#appaccountinfo)&gt; | No | Array of allowed accounts. By default, no value is passed. |
| allowedOwners | Array&lt;string&gt; | No | Allowed account owners.| | allowedOwners | Array&lt;string&gt; | No | Array of the owners of the allowed accounts. By default, no value is passed.|
| requiredLabels | Array&lt;string&gt; | No | Labels required for the authenticator. | | requiredLabels | Array&lt;string&gt; | No | Labels of the authenticator. By default, no value is passed. |
## VerifyCredentialOptions<sup>9+</sup> ## VerifyCredentialOptions<sup>9+</sup>
...@@ -4515,9 +4513,9 @@ Represents the options for verifying the user credential. ...@@ -4515,9 +4513,9 @@ Represents the options for verifying the user credential.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------------- | ---------------------- | ----- | -------------- | | -------------- | ---------------------- | ----- | -------------- |
| credentialType | string | No | Type of the credential to verify. | | credentialType | string | No | Credential type. By default, no value is passed. |
| credential | string | No | Credential value. | | credential | string | No | Credential value. By default, no value is passed. |
| parameters | {[key: string]: Object} | No | Customized parameters.| | parameters | {[key: string]: Object} | No | Custom parameter object. By default, no value is passed.|
## SetPropertiesOptions<sup>9+</sup> ## SetPropertiesOptions<sup>9+</sup>
...@@ -4528,8 +4526,8 @@ Represents the options for setting authenticator properties. ...@@ -4528,8 +4526,8 @@ Represents the options for setting authenticator properties.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | ---------------------- | ----- | -------------- | | ---------- | ---------------------- | ----- | -------------- |
| properties | {[key: string]: Object} | No | Authenticator properties. | | properties | {[key: string]: Object} | No | Property object. By default, no value is passed. |
| parameters | {[key: string]: Object} | No | Customized parameters.| | parameters | {[key: string]: Object} | No | Custom parameter object. By default, no value is passed.|
## Constants<sup>8+</sup> ## Constants<sup>8+</sup>
...@@ -4539,23 +4537,23 @@ Enumerates the constants. ...@@ -4539,23 +4537,23 @@ Enumerates the constants.
| Name | Value | Description | | Name | Value | Description |
| -------------------------------- | ---------------------- | ----------------------- | | -------------------------------- | ---------------------- | ----------------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY<sup>(deprecated)</sup> | "addAccountImplicitly" | Operation of adding an account implicitly. | | ACTION_ADD_ACCOUNT_IMPLICITLY<sup>(deprecated)</sup> | 'addAccountImplicitly' | Operation of adding an account implicitly. |
| ACTION_AUTHENTICATE<sup>(deprecated)</sup> | "authenticate" | Authentication operation. | | ACTION_AUTHENTICATE<sup>(deprecated)</sup> | 'authenticate' | Authentication operation. |
| ACTION_CREATE_ACCOUNT_IMPLICITLY<sup>9+</sup> | "createAccountImplicitly" | Operation of creating an account implicitly. | | ACTION_CREATE_ACCOUNT_IMPLICITLY<sup>9+</sup> | 'createAccountImplicitly' | Operation of creating an account implicitly. |
| ACTION_AUTH<sup>9+</sup> | "auth" | Authentication operation. | | ACTION_AUTH<sup>9+</sup> | 'auth' | Authentication operation. |
| ACTION_VERIFY_CREDENTIAL<sup>9+</sup> | "verifyCredential" | Operation of verifying credentials. | | ACTION_VERIFY_CREDENTIAL<sup>9+</sup> | 'verifyCredential' | Operation of verifying credentials. |
| ACTION_SET_AUTHENTICATOR_PROPERTIES<sup>9+</sup> | "setAuthenticatorProperties" | Operation of setting authenticator properties. | | ACTION_SET_AUTHENTICATOR_PROPERTIES<sup>9+</sup> | 'setAuthenticatorProperties' | Operation of setting authenticator properties. |
| KEY_NAME | "name" | Name of the app account. | | KEY_NAME | 'name' | Name of the app account. |
| KEY_OWNER | "owner" | Owner of the app account.| | KEY_OWNER | 'owner' | Owner of the app account.|
| KEY_TOKEN | "token" | Token. | | KEY_TOKEN | 'token' | Token. |
| KEY_ACTION | "action" | Operation. | | KEY_ACTION | 'action' | Operation. |
| KEY_AUTH_TYPE | "authType" | Authentication type. | | KEY_AUTH_TYPE | 'authType' | Authentication type. |
| KEY_SESSION_ID | "sessionId" | Session ID. | | KEY_SESSION_ID | 'sessionId' | Session ID. |
| KEY_CALLER_PID | "callerPid" | PID of the caller. | | KEY_CALLER_PID | 'callerPid' | PID of the caller. |
| KEY_CALLER_UID | "callerUid" | UID of the caller. | | KEY_CALLER_UID | 'callerUid' | UID of the caller. |
| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Bundle name of the caller. | | KEY_CALLER_BUNDLE_NAME | 'callerBundleName' | Bundle name of the caller. |
| KEY_REQUIRED_LABELS<sup>9+</sup> | "requiredLabels" | Required labels. | | KEY_REQUIRED_LABELS<sup>9+</sup> | 'requiredLabels' | Required labels. |
| KEY_BOOLEAN_RESULT<sup>9+</sup> | "booleanResult" | Return value of the Boolean type. | | KEY_BOOLEAN_RESULT<sup>9+</sup> | 'booleanResult' | Return value of the Boolean type. |
## ResultCode<sup>(deprecated)</sup> ## ResultCode<sup>(deprecated)</sup>
...@@ -4606,27 +4604,27 @@ Called to return the result of an authentication request. ...@@ -4606,27 +4604,27 @@ Called to return the result of an authentication request.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | -------------------- | ---- | ------ | | ------ | -------------------- | ---- | ------ |
| code | number | Yes | Authentication result code.| | code | number | Yes | Authentication result code.|
| result | [AuthResult](#authresult9) | No | Authentication result. | | result | [AuthResult](#authresult9) | No | Authentication result. By default, no value is passed, which means the authentication result is not received. |
**Example** **Example**
```js ```js
let appAccountManager = account_appAccount.createAppAccountManager(); let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = '1234';
appAccountManager.getAuthCallback(sessionId).then((callback) => { appAccountManager.getAuthCallback(sessionId).then((callback) => {
var result = { var result = {
accountInfo: { accountInfo: {
name: "Lisi", name: 'Lisi',
owner: "com.example.accountjsdemo", owner: 'com.example.accountjsdemo',
}, },
tokenInfo: { tokenInfo: {
token: "xxxxxx", token: 'xxxxxx',
authType: "getSocialData" authType: 'getSocialData'
} }
}; };
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthCallback err: " + JSON.stringify(err)); console.log('getAuthCallback err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4650,20 +4648,20 @@ Called to redirect a request. ...@@ -4650,20 +4648,20 @@ Called to redirect a request.
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
createAccountImplicitly(options, callback) { createAccountImplicitly(options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.accountjsdemo", bundleName: 'com.example.accountjsdemo',
abilityName: "com.example.accountjsdemo.LoginAbility", abilityName: 'com.example.accountjsdemo.LoginAbility',
}); });
} }
auth(name, authType, options, callback) { auth(name, authType, options, callback) {
var result = { var result = {
accountInfo: { accountInfo: {
name: "Lisi", name: 'Lisi',
owner: "com.example.accountjsdemo", owner: 'com.example.accountjsdemo',
}, },
tokenInfo: { tokenInfo: {
token: "xxxxxx", token: 'xxxxxx',
authType: "getSocialData" authType: 'getSocialData'
} }
}; };
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
...@@ -4683,11 +4681,11 @@ Called to continue to process the request. ...@@ -4683,11 +4681,11 @@ Called to continue to process the request.
```js ```js
let appAccountManager = account_appAccount.createAppAccountManager(); let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = '1234';
appAccountManager.getAuthCallback(sessionId).then((callback) => { appAccountManager.getAuthCallback(sessionId).then((callback) => {
callback.onRequestContinued(); callback.onRequestContinued();
}).catch((err) => { }).catch((err) => {
console.log("getAuthCallback err: " + JSON.stringify(err)); console.log('getAuthCallback err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4718,15 +4716,15 @@ Called to return the result of an authentication request. ...@@ -4718,15 +4716,15 @@ Called to return the result of an authentication request.
```js ```js
let appAccountManager = account_appAccount.createAppAccountManager(); let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = '1234';
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
var result = {[account_appAccount.Constants.KEY_NAME]: "LiSi", var result = {[account_appAccount.Constants.KEY_NAME]: 'LiSi',
[account_appAccount.Constants.KEY_OWNER]: "com.example.accountjsdemo", [account_appAccount.Constants.KEY_OWNER]: 'com.example.accountjsdemo',
[account_appAccount.Constants.KEY_AUTH_TYPE]: "getSocialData", [account_appAccount.Constants.KEY_AUTH_TYPE]: 'getSocialData',
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4750,15 +4748,15 @@ Called to redirect a request. ...@@ -4750,15 +4748,15 @@ Called to redirect a request.
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.accountjsdemo", bundleName: 'com.example.accountjsdemo',
abilityName: "com.example.accountjsdemo.LoginAbility", abilityName: 'com.example.accountjsdemo.LoginAbility',
}); });
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {[account_appAccount.Constants.KEY_NAME]: name, var result = {[account_appAccount.Constants.KEY_NAME]: name,
[account_appAccount.Constants.KEY_AUTH_TYPE]: authType, [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
} }
...@@ -4776,11 +4774,11 @@ Called to continue to process the request. ...@@ -4776,11 +4774,11 @@ Called to continue to process the request.
```js ```js
let appAccountManager = account_appAccount.createAppAccountManager(); let appAccountManager = account_appAccount.createAppAccountManager();
var sessionId = "1234"; var sessionId = '1234';
appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
callback.onRequestContinued(); callback.onRequestContinued();
}).catch((err) => { }).catch((err) => {
console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); console.log('getAuthenticatorCallback err: ' + JSON.stringify(err));
}); });
``` ```
...@@ -4940,22 +4938,22 @@ Obtains the remote object of an authenticator. This API cannot be overloaded. ...@@ -4940,22 +4938,22 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
class MyAuthenticator extends account_appAccount.Authenticator { class MyAuthenticator extends account_appAccount.Authenticator {
addAccountImplicitly(authType, callerBundleName, options, callback) { addAccountImplicitly(authType, callerBundleName, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.accountjsdemo", bundleName: 'com.example.accountjsdemo',
abilityName: "com.example.accountjsdemo.LoginAbility", abilityName: 'com.example.accountjsdemo.LoginAbility',
}); });
} }
authenticate(name, authType, callerBundleName, options, callback) { authenticate(name, authType, callerBundleName, options, callback) {
var result = {[account_appAccount.Constants.KEY_NAME]: name, var result = {[account_appAccount.Constants.KEY_NAME]: name,
[account_appAccount.Constants.KEY_AUTH_TYPE]: authType, [account_appAccount.Constants.KEY_AUTH_TYPE]: authType,
[account_appAccount.Constants.KEY_TOKEN]: "xxxxxx"}; [account_appAccount.Constants.KEY_TOKEN]: 'xxxxxx'};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result); callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
} }
verifyCredential(name, options, callback) { verifyCredential(name, options, callback) {
callback.onRequestRedirected({ callback.onRequestRedirected({
bundleName: "com.example.accountjsdemo", bundleName: 'com.example.accountjsdemo',
abilityName: "com.example.accountjsdemo.VerifyAbility", abilityName: 'com.example.accountjsdemo.VerifyAbility',
parameters: { parameters: {
name: name name: name
} }
......
...@@ -62,12 +62,14 @@ Obtains distributed account information. This API uses an asynchronous callback ...@@ -62,12 +62,14 @@ Obtains distributed account information. This API uses an asynchronous callback
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfo((err, data) => { accountAbility.getOsAccountDistributedInfo((err, data) => {
console.log("getOsAccountDistributedInfo err: " + JSON.stringify(err)); if (err) {
console.log('Query account info name: ' + data.name); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
console.log('Query account info id: ' + data.id); } else {
console.log('distributed information: ' + JSON.stringify(data));
}
}); });
} catch (e) { } catch (err) {
console.log("getOsAccountDistributedInfo exception: " + JSON.stringify(e)); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -98,15 +100,96 @@ Obtains distributed account information. This API uses a promise to return the r ...@@ -98,15 +100,96 @@ Obtains distributed account information. This API uses a promise to return the r
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfo().then((data) => { accountAbility.getOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name); console.log('distributed information: ' + JSON.stringify(data));
console.log('Query account info id: ' + data.id);
}).catch((err) => { }).catch((err) => {
console.log("getOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (err) {
console.log("getOsAccountDistributedInfo exception: " + JSON.stringify(e)); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} }
``` ```
### getOsAccountDistributedInfoByLocalId<sup>10+</sup>
getOsAccountDistributedInfoByLocalId(localId: number, callback: AsyncCallback&lt;DistributedInfo&gt;): void
Obtains distributed information about an OS account. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| localId | number | Yes| ID of the target OS account.|
| callback | AsyncCallback&lt;[DistributedInfo](#distributedinfo)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **undefined** and **data** is the distributed account information obtained. Otherwise, **err** is an error object.|
**Error codes**
| ID| Error Message|
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300003 | Account not found. |
**Example**
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfoByLocalId(100, (err, data) => {
if (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
} catch (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
```
### getOsAccountDistributedInfoByLocalId<sup>10+</sup>
getOsAccountDistributedInfoByLocalId(localId: number): Promise&lt;DistributedInfo&gt;
Obtains distributed information about an OS account. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[DistributedInfo](#distributedinfo)&gt; | Promise used to return the distributed account information obtained.|
**Error codes**
| ID| Error Message|
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300003 | Account not found. |
**Example**
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfoByLocalId(100).then((data) => {
console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
});
} catch (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
```
### queryOsAccountDistributedInfo<sup>(deprecated)</sup> ### queryOsAccountDistributedInfo<sup>(deprecated)</sup>
queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): void queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): void
...@@ -130,9 +213,11 @@ Obtains distributed account information. This API uses an asynchronous callback ...@@ -130,9 +213,11 @@ Obtains distributed account information. This API uses an asynchronous callback
```js ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => { accountAbility.queryOsAccountDistributedInfo((err, data) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); if (err) {
console.log('Query account info name: ' + data.name); console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
console.log('Query account info id: ' + data.id); } else {
console.log('distributed information: ' + JSON.stringify(data));
}
}); });
``` ```
...@@ -160,10 +245,9 @@ Obtains distributed account information. This API uses a promise to return the r ...@@ -160,10 +245,9 @@ Obtains distributed account information. This API uses a promise to return the r
```js ```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => { accountAbility.queryOsAccountDistributedInfo().then((data) => {
console.log('Query account info name: ' + data.name); console.log('distributed information: ' + JSON.stringify(data));
console.log('Query account info id: ' + data.id);
}).catch((err) => { }).catch((err) => {
console.log("queryOsAccountDistributedInfoerr: " + JSON.stringify(err)); console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
``` ```
...@@ -198,10 +282,14 @@ Sets the distributed account information. This API uses an asynchronous callback ...@@ -198,10 +282,14 @@ Sets the distributed account information. This API uses an asynchronous callback
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.setOsAccountDistributedInfo(accountInfo, (err) => {
console.log("setOsAccountDistributedInfo err: " + JSON.stringify(err)); if (err) {
console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('setOsAccountDistributedInfo successfully');
}
}); });
} catch (e) { } catch (err) {
console.log("setOsAccountDistributedInfo exception: " + JSON.stringify(e)); console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} }
``` ```
...@@ -241,14 +329,109 @@ Sets the distributed account information. This API uses a promise to return the ...@@ -241,14 +329,109 @@ Sets the distributed account information. This API uses a promise to return the
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => {
console.log('setOsAccountDistributedInfo Success'); console.log('setOsAccountDistributedInfo successfully');
}).catch((err) => { }).catch((err) => {
console.log("setOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
} catch (e) { } catch (err) {
console.log("setOsAccountDistributedInfo exception: " + JSON.stringify(e)); console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} }
``` ```
### setOsAccountDistributedInfoByLocalId<sup>10+</sup>
setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: DistributedInfo, callback: AsyncCallback&lt;void&gt;): void
Sets the distributed information for an OS account. This API uses an asynchronous callback to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| localId | number | Yes| ID of the target OS account.|
| accountInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the distributed information is set successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes**
| ID| Error Message|
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid distributedInfo. |
| 12300003 | Account identified by localId or by distributedInfo not found. |
| 12300008 | Restricted OS account. |
**Example**
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo, (err) => {
if (err) {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else {
console.log('setOsAccountDistributedInfoByLocalId successfully');
}
});
} catch (err) {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
```
### setOsAccountDistributedInfoByLocalId<sup>10+</sup>
setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: DistributedInfo): Promise&lt;void&gt;
Sets the distributed information for an OS account. This API uses a promise to return the result.
**System API**: This is a system API.
**System capability**: SystemCapability.Account.OsAccount
**Required permissions**: ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| localId | number | Yes| ID of the target OS account.|
| distributedInfo | [DistributedInfo](#distributedinfo) | Yes| Distributed account information to set.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
| ID| Error Message|
| -------- | ------------------- |
| 12300001 | System service exception. |
| 12300002 | Invalid distributedInfo. |
| 12300003 | Account identified by localId or by distributedInfo not found. |
| 12300008 | Restricted OS account. |
**Example**
```js
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo).then(() => {
console.log('setOsAccountDistributedInfoByLocalId successfully');
}).catch((err) => {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
});
} catch (err) {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
```
### updateOsAccountDistributedInfo<sup>(deprecated)</sup> ### updateOsAccountDistributedInfo<sup>(deprecated)</sup>
updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback&lt;void&gt;): void updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallback&lt;void&gt;): void
...@@ -275,7 +458,11 @@ Updates the distributed account information. This API uses an asynchronous callb ...@@ -275,7 +458,11 @@ Updates the distributed account information. This API uses an asynchronous callb
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('queryOsAccountDistributedInfo successfully');
}
}); });
``` ```
...@@ -308,22 +495,34 @@ Updates the distributed account information. This API uses a promise to return t ...@@ -308,22 +495,34 @@ Updates the distributed account information. This API uses a promise to return t
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
console.log('updateOsAccountDistributedInfo Success'); console.log('updateOsAccountDistributedInfo successfully');
}).catch((err) => { }).catch((err) => {
console.log("updateOsAccountDistributedInfo err: " + JSON.stringify(err)); console.log('updateOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
``` ```
## DistributedInfo ## DistributedInfo
Defines distributed OS account information. Defines the distributed information about an OS account.
**System capability**: SystemCapability.Account.OsAccount
| Name| Type| Read-only| Mandatory| Description|
| -------- | -------- | -------- |-------- | -------- |
| name | string | No|Yes| Name of the distributed account. It must be a non-null string.|
| id | string | No|Yes| UID of the distributed account. It must be a non-null string.|
| event | string | No|Yes| Login state of the distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF |
| nickname<sup>9+</sup> | string | No|No| Nickname of the distributed account. By default, no value is passed.|
| avatar<sup>9+</sup> | string | No|No| Avatar of the distributed account. By default, no value is passed.|
| status<sup>10+</sup> | [DistributedAccountStatus](#distributedaccountstatus10) | Yes|No| Status of the distributed account. The value is of the enumerated type. The default status is unlogged.|
| scalableData<sup>8+</sup> | object | No|No| Extended information about the distributed account, passed in key-value (KV) pairs based on service requirements. By default, no value is passed.|
## DistributedAccountStatus<sup>10+</sup>
Enumerates the statuses of a distributed account.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name| Type| Mandatory| Description| | Name | Value| Description |
| -------- | -------- | -------- | -------- | | ---- | ------ | ----------- |
| name | string | Yes| Name of the distributed account. It must be a non-null string.| | NOT_LOGGED_IN | 0 | The account has not logged in.|
| id | string | Yes| UID of the distributed account. It must be a non-null string.| | LOGGED_IN | 1 | The account has logged in.|
| event | string | Yes| Login state of the distributed account. The state can be login, logout, token invalid, or logoff, which correspond to the following strings respectively:<br>-&nbsp;Ohos.account.event.LOGIN<br>-&nbsp;Ohos.account.event.LOGOUT<br>-&nbsp;Ohos.account.event.TOKEN_INVALID<br>-&nbsp;Ohos.account.event.LOGOFF |
| nickname<sup>9+</sup> | string | No| Nickname of the distributed account. It must be a non-null string.|
| avatar<sup>9+</sup> | string | No| Avatar of the distributed account. It must be a non-null string.|
| scalableData<sup>8+</sup> | object | No| Extended information about the distributed account, passed in key-value (KV) pairs.<br>**NOTE**<br>This parameter is reserved and not used in the setters and getters.|
...@@ -2433,7 +2433,7 @@ Unsubscribes from the OS account activation states, including the states of the ...@@ -2433,7 +2433,7 @@ Unsubscribes from the OS account activation states, including the states of the
| -------- | -------------------------- | ---- | ------------------------------------------------------------ | | -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.| | type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated.|
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.| | name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.|
| callback | Callback&lt;number&gt; | No | Callback to unregister. By default, **0** is returned. | | callback | Callback&lt;number&gt; | No | Callback for the OS account activation state events. By default, no value is passed, which unsubscribes from all the callbacks for the OS account activation state events. |
**Error codes** **Error codes**
...@@ -5649,7 +5649,7 @@ Obtains authentication information of the specified type. This API uses a promis ...@@ -5649,7 +5649,7 @@ Obtains authentication information of the specified type. This API uses a promis
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------- | | -------- | ----------------------------------- | ---- | -------- |
| authType | [AuthType](#authtype8) | No | Authentication credential type.| | authType | [AuthType](#authtype8) | No | Authentication type. By default, no value is passed, which means to obtain information about all authentication types.|
**Return value** **Return value**
...@@ -5929,12 +5929,14 @@ Defines the executor property. ...@@ -5929,12 +5929,14 @@ Defines the executor property.
**System capability**: SystemCapability.Account.OsAccount **System capability**: SystemCapability.Account.OsAccount
| Name | Type | Mandatory | Description | | Name | Type | Readable| Writable| Description |
| ------------ | ---------------------------------------- | ----- | ----------------- | | ------------ | ---------------------------- | ----- | -----|----------------- |
| result | number | Yes | Result. | | result | number | Yes | Yes | Result. |
| authSubType | [AuthSubType](#authsubtype8) | Yes | Authentication credential subtype.| | authSubType | [AuthSubType](#authsubtype8) | Yes | Yes | Authentication credential subtype.|
| remainTimes | number | No | Number of remaining authentication times. | | remainTimes | number | Yes | Yes | Number of remaining authentication times. |
| freezingTime | number | No | Freezing time. | | freezingTime | number | Yes | Yes | Freezing time. |
| enrollmentProgress<sup>10+</sup> | string | Yes | Yes | Enrollment progress. By default, no value is passed.|
| sensorInfo<sup>10+</sup> | string | Yes | Yes | Sensor information. By default, no value is passed.|
## AuthResult<sup>8+</sup> ## AuthResult<sup>8+</sup>
...@@ -5946,9 +5948,9 @@ Defines the authentication result information. ...@@ -5946,9 +5948,9 @@ Defines the authentication result information.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ----------- | ----- | ----------------- | | ------------ | ----------- | ----- | ----------------- |
| token | Uint8Array | No | Authentication token. | | token | Uint8Array | No | Authentication token. By default, no value is passed. |
| remainTimes | number | No | Number of remaining authentication times. | | remainTimes | number | No | Number of remaining authentication times. By default, no value is passed. |
| freezingTime | number | No | Freezing time. | | freezingTime | number | No | Freezing time. By default, no value is passed. |
## CredentialInfo<sup>8+</sup> ## CredentialInfo<sup>8+</sup>
...@@ -5974,7 +5976,7 @@ Defines the request result information. ...@@ -5974,7 +5976,7 @@ Defines the request result information.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------------ | ----------- | ----- | ----------------- | | ------------ | ----------- | ----- | ----------------- |
| credentialId | Uint8Array | No | Credential ID. | | credentialId | Uint8Array | No | Credential ID. By default, no value is passed. |
## EnrolledCredInfo<sup>8+</sup> ## EnrolledCredInfo<sup>8+</sup>
...@@ -6004,6 +6006,8 @@ Enumerates the types of properties to obtain. ...@@ -6004,6 +6006,8 @@ Enumerates the types of properties to obtain.
| AUTH_SUB_TYPE | 1 | Authentication credential subtype.| | AUTH_SUB_TYPE | 1 | Authentication credential subtype.|
| REMAIN_TIMES | 2 | Remaining time. | | REMAIN_TIMES | 2 | Remaining time. |
| FREEZING_TIME | 3 | Freezing time. | | FREEZING_TIME | 3 | Freezing time. |
| ENROLLMENT_PROGRESS<sup>10+</sup> | 4 | Enrollment progress. |
| SENSOR_INFO<sup>10+</sup> | 5 | Sensor information. |
## SetPropertyType<sup>8+</sup> ## SetPropertyType<sup>8+</sup>
...@@ -6047,6 +6051,9 @@ Enumerates the authentication credential subtypes. ...@@ -6047,6 +6051,9 @@ Enumerates the authentication credential subtypes.
| PIN_MIXED | 10002 | Custom mixed credentials.| | PIN_MIXED | 10002 | Custom mixed credentials.|
| FACE_2D | 20000 | 2D face credential. | | FACE_2D | 20000 | 2D face credential. |
| FACE_3D | 20001 | 3D face credential. | | FACE_3D | 20001 | 3D face credential. |
| FINGERPRINT_CAPACITIVE<sup>10+</sup> | 30000 | Capacitive fingerprint. |
| FINGERPRINT_OPTICAL<sup>10+</sup> | 30001 | Optical fingerprint. |
| FINGERPRINT_ULTRASONIC<sup>10+</sup> | 30002 | Ultrasonic fingerprint. |
| DOMAIN_MIXED<sup>9+</sup> | 10240001 | Mixed domain authentication credentials. | | DOMAIN_MIXED<sup>9+</sup> | 10240001 | Mixed domain authentication credentials. |
## AuthTrustLevel<sup>8+</sup> ## AuthTrustLevel<sup>8+</sup>
...@@ -6136,6 +6143,8 @@ Enumerates the tip codes for fingerprint authentication. ...@@ -6136,6 +6143,8 @@ Enumerates the tip codes for fingerprint authentication.
| FINGERPRINT_TIP_PARTIAL | 3 | Only part of the fingerprint image is detected. | | FINGERPRINT_TIP_PARTIAL | 3 | Only part of the fingerprint image is detected. |
| FINGERPRINT_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to quick motion. | | FINGERPRINT_TIP_TOO_FAST | 4 | The fingerprint image is incomplete due to quick motion. |
| FINGERPRINT_TIP_TOO_SLOW | 5 | Failed to read the fingerprint image due to lack of motion. | | FINGERPRINT_TIP_TOO_SLOW | 5 | Failed to read the fingerprint image due to lack of motion. |
| FINGERPRINT_TIP_FINGER_DOWN<sup>10+</sup> | 6 | Press your finger. |
| FINGERPRINT_TIP_FINGER_UP<sup>10+</sup> | 7 | Lift your finger. |
## OsAccountInfo ## OsAccountInfo
...@@ -6148,16 +6157,16 @@ Defines the OS account information. ...@@ -6148,16 +6157,16 @@ Defines the OS account information.
| localId | number | Yes | ID of the target OS account. | | localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | OS account name. | | localName | string | Yes | OS account name. |
| type | [OsAccountType](#osaccounttype) | Yes | OS account type. | | type | [OsAccountType](#osaccounttype) | Yes | OS account type. |
| constraints | Array&lt;string&gt; | No | [Constraints](#constraints) on the OS account.| | constraints | Array&lt;string&gt; | No | OS account [Constraints](#constraints). By default, no value is passed.|
| isVerified<sup>8+</sup> | boolean | Yes | Whether to verify the OS account. | | isVerified<sup>8+</sup> | boolean | Yes | Whether to verify the OS account. |
| photo<sup>8+</sup> | string | No | Profile photo of the OS account. | | photo<sup>8+</sup> | string | No | OS account avatar. By default, no value is passed. |
| createTime<sup>8+</sup> | number | Yes | Time when the OS account was created. | | createTime<sup>8+</sup> | number | Yes | Time when the OS account was created. |
| lastLoginTime<sup>8+</sup> | number | No | Last login time of the OS account. | | lastLoginTime<sup>8+</sup> | number | No | Last login time of the OS account. By default, no value is passed. |
| serialNumber<sup>8+</sup> | number | Yes | SN of the OS account. | | serialNumber<sup>8+</sup> | number | Yes | SN of the OS account. |
| isActived<sup>8+</sup> | boolean | Yes | Whether the OS account is activated. | | isActived<sup>8+</sup> | boolean | Yes | Whether the OS account is activated. |
| isCreateCompleted<sup>8+</sup> | boolean | Yes | Whether the OS account information is complete. | | isCreateCompleted<sup>8+</sup> | boolean | Yes | Whether the OS account information is complete. |
| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. | | distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. By default, no value is passed. |
| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | No | Domain account information. | | domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | No | Domain account information. By default, no value is passed. |
## DomainAccountInfo<sup>8+</sup> ## DomainAccountInfo<sup>8+</sup>
...@@ -6169,7 +6178,7 @@ Defines the domain account information. ...@@ -6169,7 +6178,7 @@ Defines the domain account information.
| ----------- | ------ | ---- | ---------- | | ----------- | ------ | ---- | ---------- |
| domain | string | Yes | Domain name. | | domain | string | Yes | Domain name. |
| accountName | string | Yes | Domain account name.| | accountName | string | Yes | Domain account name.|
| accountId<sup>10+</sup> | string | No | Domain account ID.<br>**System API**: This is a system API.| | accountId<sup>10+</sup> | string | No | Domain account ID.<br>**System API**: It is a system API and is left blank by default.|
## Constraints ## Constraints
......
...@@ -59,7 +59,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -59,7 +59,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0).then(() => { privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.PERMISSION_USED_STATS', 1, 0).then(() => {
console.log('addPermissionUsedRecord success'); console.log('addPermissionUsedRecord success');
}).catch((err) => { }).catch((err) => {
console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`); console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
...@@ -88,7 +88,7 @@ The permission usage record includes the application identity (token ID) of the ...@@ -88,7 +88,7 @@ The permission usage record includes the application identity (token ID) of the
| permissionName | Permissions | Yes | Name of the permission.| | permissionName | Permissions | Yes | Name of the permission.|
| successCount | number | Yes | Number of successful accesses.| | successCount | number | Yes | Number of successful accesses.|
| failCount | number | Yes | Number of failed accesses.| | failCount | number | Yes | Number of failed accesses.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If a usage record is added successfully, **err** is **undefine**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If a usage record is added successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -109,7 +109,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -109,7 +109,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.addPermissionUsedRecord(tokenID, "ohos.permission.PERMISSION_USED_STATS", 1, 0, (err, data) => { privacyManager.addPermissionUsedRecord(tokenID, 'ohos.permission.PERMISSION_USED_STATS', 1, 0, (err, data) => {
if (err) { if (err) {
console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`); console.log(`addPermissionUsedRecord fail, err->${JSON.stringify(err)}`);
} else { } else {
...@@ -161,14 +161,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ...@@ -161,14 +161,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import privacyManager from '@ohos.privacyManager'; import privacyManager from '@ohos.privacyManager';
let request = { let request = {
"tokenId": 1, 'tokenId': 1,
"isRemote": false, 'isRemote': false,
"deviceId": "device", 'deviceId': 'device',
"bundleName": "bundle", 'bundleName': 'bundle',
"permissionNames": [], 'permissionNames': [],
"beginTime": 0, 'beginTime': 0,
"endTime": 1, 'endTime': 1,
"flag":privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL, 'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
}; };
try { try {
privacyManager.getPermissionUsedRecord(request).then((data) => { privacyManager.getPermissionUsedRecord(request).then((data) => {
...@@ -196,7 +196,7 @@ Obtains historical permission usage records. This API uses an asynchronous callb ...@@ -196,7 +196,7 @@ Obtains historical permission usage records. This API uses an asynchronous callb
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ | | -------- | ------------------- | ---- | ------------------------------------------ |
| request | [PermissionUsedRequest](#permissionusedrequest) | Yes| Request for querying permission usage records.| | request | [PermissionUsedRequest](#permissionusedrequest) | Yes| Request for querying permission usage records.|
| callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | Yes| Callback invoked to return the result. If the query is successful, **err** is **undefine** and **data** is the permission usage record. Otherwise, **err** is an error object.| | callback | AsyncCallback<[PermissionUsedResponse](#permissionusedresponse)> | Yes| Callback invoked to return the result. If the query is successful, **err** is **undefined** and **data** is the permission usage record. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -216,14 +216,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ...@@ -216,14 +216,14 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
import privacyManager from '@ohos.privacyManager'; import privacyManager from '@ohos.privacyManager';
let request = { let request = {
"tokenId": 1, 'tokenId': 1,
"isRemote": false, 'isRemote': false,
"deviceId": "device", 'deviceId': 'device',
"bundleName": "bundle", 'bundleName': 'bundle',
"permissionNames": [], 'permissionNames': [],
"beginTime": 0, 'beginTime': 0,
"endTime": 1, 'endTime': 1,
"flag":privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL, 'flag':privacyManager.PermissionUsageFlag.FLAG_PERMISSION_USAGE_DETAIL,
}; };
try { try {
privacyManager.getPermissionUsedRecord(request, (err, data) => { privacyManager.getPermissionUsedRecord(request, (err, data) => {
...@@ -281,7 +281,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -281,7 +281,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.startUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS").then(() => { privacyManager.startUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS').then(() => {
console.log('startUsingPermission success'); console.log('startUsingPermission success');
}).catch((err) => { }).catch((err) => {
console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`); console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`);
...@@ -307,7 +307,7 @@ Starts to use a permission and flushes the permission usage record. This API is ...@@ -307,7 +307,7 @@ Starts to use a permission and flushes the permission usage record. This API is
| -------------- | --------------------- | ---- | ------------------------------------ | | -------------- | --------------------- | ---- | ------------------------------------ |
| tokenID | number | Yes | Application token ID of the invoker. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md).| | tokenID | number | Yes | Application token ID of the invoker. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md).|
| permissionName | Permissions | Yes | Permission to use. | | permissionName | Permissions | Yes | Permission to use. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the permission is successfully used, **err** is **undefine**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the permission is successfully used, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -329,7 +329,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -329,7 +329,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.startUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS", (err, data) => { privacyManager.startUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS', (err, data) => {
if (err) { if (err) {
console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`); console.log(`startUsingPermission fail, err->${JSON.stringify(err)}`);
} else { } else {
...@@ -384,7 +384,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -384,7 +384,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.stopUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS").then(() => { privacyManager.stopUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS').then(() => {
console.log('stopUsingPermission success'); console.log('stopUsingPermission success');
}).catch((err) => { }).catch((err) => {
console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`); console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
...@@ -410,7 +410,7 @@ Stops using a permission. This API is called by a system application and uses a ...@@ -410,7 +410,7 @@ Stops using a permission. This API is called by a system application and uses a
| -------------- | --------------------- | ---- | ------------------------------------ | | -------------- | --------------------- | ---- | ------------------------------------ |
| tokenID | number | Yes | Application token ID of the invoker. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md).| | tokenID | number | Yes | Application token ID of the invoker. The value can be obtained from [ApplicationInfo](js-apis-bundle-ApplicationInfo.md).|
| permissionName | Permissions | Yes | Permission to use. | | permissionName | Permissions | Yes | Permission to use. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefine**. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;void&gt; | Yes | Callback invoked to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
**Error codes** **Error codes**
...@@ -432,7 +432,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -432,7 +432,7 @@ import privacyManager from '@ohos.privacyManager';
let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID. let tokenID = 0; // You can use getApplicationInfo to obtain the access token ID.
try { try {
privacyManager.stopUsingPermission(tokenID, "ohos.permission.PERMISSION_USED_STATS", (err, data) => { privacyManager.stopUsingPermission(tokenID, 'ohos.permission.PERMISSION_USED_STATS', (err, data) => {
if (err) { if (err) {
console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`); console.log(`stopUsingPermission fail, err->${JSON.stringify(err)}`);
} else { } else {
...@@ -482,7 +482,7 @@ import privacyManager from '@ohos.privacyManager'; ...@@ -482,7 +482,7 @@ import privacyManager from '@ohos.privacyManager';
let permissionList = []; let permissionList = [];
try { try {
privacyManager.on('activeStateChange', permissionList, (data) => { privacyManager.on('activeStateChange', permissionList, (data) => {
console.debug("receive permission state change, data:" + JSON.stringify(data)); console.debug('receive permission state change, data:' + JSON.stringify(data));
}); });
} catch(err) { } catch(err) {
console.log(`catch err->${JSON.stringify(err)}`); console.log(`catch err->${JSON.stringify(err)}`);
...@@ -514,7 +514,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e ...@@ -514,7 +514,7 @@ For details about the error codes, see [Ability Access Control Error Codes](../e
| ID| Error Message| | ID| Error Message|
| -------- | -------- | | -------- | -------- |
| 12100001 | The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. | | 12100001 | The permissionNames in the list are all invalid, or the list size exceeds 1024 bytes. |
| 12100004 | The interface is not used together with "on()".| | 12100004 | The interface is not used together with 'on'.|
| 12100007 | Service is abnormal. | | 12100007 | Service is abnormal. |
| 12100008 | Out of memory. | | 12100008 | Out of memory. |
...@@ -550,14 +550,14 @@ Represents the request for querying permission usage records. ...@@ -550,14 +550,14 @@ Represents the request for querying permission usage records.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------- | ---- | ---------------------------------------- | | -------- | -------------- | ---- | ---------------------------------------- |
| tokenId | number | No | Token ID of the application (invoker). | | tokenId | number | No | Token ID of the application (invoker).<br>By default, all applications are queried. |
| isRemote | boolean | No | Whether the token ID belongs to the application on a remote device. The default value is **false**.| | isRemote | boolean | No | Whether to query the permission usage records of the remote device.<br> The default value is **false**, which means the permission usage records of the local device are queried by default.|
| deviceId | string | No | ID of the device hosting the target application. | | deviceId | string | No | ID of the device hosting the target application.<br> The default value is the local device ID. |
| bundleName | string | No | Bundle name of the target application.| | bundleName | string | No | Bundle name of the target application.<br>By default, all applications are queried.|
| permissionNames | Array&lt;Permissions&gt; | No | Permissions to query. | | permissionNames | Array&lt;Permissions&gt; | No | Permissions to query.<br>By default, the usage records of all permissions are queried. |
| beginTime | number | No | Start time of the query, in ms. The default value is **0**, indicating that no start time is set.| | beginTime | number | No | Start time of the query, in ms.<br>The default value is **0**, which means the start time is not set.|
| endTime | number | No | End time of the query, in ms. The default value is **0**, indicating that no end time is set.| | endTime | number | No | End time of the query, in ms.<br>The default value is **0**, which means the end time is not set.|
| flag | [PermissionUsageFlag](#permissionusageflag) | Yes | Query mode. The default value is **FLAG_PERMISSION_USAGE_SUMMARY**.| | flag | [PermissionUsageFlag](#permissionusageflag) | Yes | Query mode.|
## PermissionUsedResponse ## PermissionUsedResponse
...@@ -567,9 +567,9 @@ Represents the permission usage records of all applications. ...@@ -567,9 +567,9 @@ Represents the permission usage records of all applications.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------- | ---- | ---------------------------------------- | | -------- | -------------- | ---- | ---------------------------------------- |
| beginTime | number | No | Start time of the query, in ms.| | beginTime | number | Yes | Start time of the query, in ms.|
| endTime | number | No | End time of the query, in ms.| | endTime | number | Yes | End time of the query, in ms.|
| bundleRecords | Array&lt;[BundleUsedRecord](#bundleusedrecord)&gt; | No | Permission usage records. | | bundleRecords | Array&lt;[BundleUsedRecord](#bundleusedrecord)&gt; | Yes | Permission usage records. |
## BundleUsedRecord ## BundleUsedRecord
...@@ -579,11 +579,11 @@ Represents the permission access records of an application. ...@@ -579,11 +579,11 @@ Represents the permission access records of an application.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------- | ---- | ---------------------------------------- | | -------- | -------------- | ---- | ---------------------------------------- |
| tokenId | number | No | Token ID of the application (invoker). | | tokenId | number | Yes | Token ID of the application (invoker). |
| isRemote | boolean | No | Whether the token ID belongs to the application on a remote device. The default value is **false**.| | isRemote | boolean | Yes | Whether the token ID belongs to the application on a remote device. The default value is **false**.|
| deviceId | string | No | ID of the device hosting the target application. | | deviceId | string | Yes | ID of the device hosting the target application. |
| bundleName | string | No | Bundle name of the target application.| | bundleName | string | Yes | Bundle name of the target application.|
| permissionRecords | Array&lt;[PermissionUsedRecord](#permissionusedrecord)&gt; | No | Permission usage records of the target application. | | permissionRecords | Array&lt;[PermissionUsedRecord](#permissionusedrecord)&gt; | Yes | Permission usage records of the target application. |
## PermissionUsedRecord ## PermissionUsedRecord
...@@ -593,14 +593,14 @@ Represents the usage records of a permission. ...@@ -593,14 +593,14 @@ Represents the usage records of a permission.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------- | ---- | ---------------------------------------- | | -------- | -------------- | ---- | ---------------------------------------- |
| permissionName | Permissions | No | Name of the permission. | | permissionName | Permissions | Yes | Name of the permission. |
| accessCount | number | No | Total number of times that the permission is accessed.| | accessCount | number | Yes | Total number of times that the permission is accessed.|
| rejectCount | number | No | Total number of times that the access to the permission is rejected.| | rejectCount | number | Yes | Total number of times that the access to the permission is rejected.|
| lastAccessTime | number | No | Last time when the permission was accessed, accurate to ms.| | lastAccessTime | number | Yes | Last time when the permission was accessed, accurate to ms.|
| lastRejectTime | number | No | Last time when the access to the permission was rejected, accurate to ms.| | lastRejectTime | number | Yes | Last time when the access to the permission was rejected, accurate to ms.|
| lastAccessDuration | number | No | Last access duration, in ms.| | lastAccessDuration | number | Yes | Last access duration, in ms.|
| accessRecords | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt; | No | Successful access records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. | | accessRecords | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt; | Yes | Successful access records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. |
| rejectRecords | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt; | No | Rejected access records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. | | rejectRecords | Array&lt;[UsedRecordDetail](#usedrecorddetail)&gt; | Yes | Rejected access records. This parameter is valid only when **flag** is **FLAG_PERMISSION_USAGE_SUMMARY**. By default, 10 records are provided. |
## UsedRecordDetail ## UsedRecordDetail
...@@ -610,9 +610,9 @@ Represents the details of a single access record. ...@@ -610,9 +610,9 @@ Represents the details of a single access record.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------- | ---- | ---------------------------------------- | | -------- | -------------- | ---- | ---------------------------------------- |
| status | number | No | Access status. | | status | number | Yes | Access status. |
| timestamp | number | No | Access timestamp, in ms.| | timestamp | number | Yes | Access timestamp, in ms.|
| accessDuration | number | No | Access duration, in ms. | | accessDuration | number | Yes | Access duration, in ms. |
## PermissionActiveStatus ## PermissionActiveStatus
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册