• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# PermissionRequestResult
2
3The **PermissionRequestResult** module defines the result of a permission request. The result is returned when [requestPermissionsFromUser](js-apis-abilityAccessCtrl.md#requestpermissionsfromuser9) is called to request permissions.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - The APIs of this module can be used only in the stage model.
9
10## Attributes
11
12**System capability**: SystemCapability.Security.AccessToken
13
14| Name| Type| Readable| Writable| Description|
15| -------- | -------- | -------- | -------- | -------- |
16| permissions | Array<string> | Yes| No| Permissions requested.|
17| authResults | Array&lt;number&gt; | Yes| No| Result of the permission request.<br>- **-1**: The permission is not authorized and must be set in **Settings** without displaying a dialog box.<br>- **0**: The permission is authorized.<br>- **2**: The permission is not authorized due to an invalid request. The possible causes are as follows:<br>  - The permission is not declared in the configuration file.<br>  - The permission name is invalid.<br>  - Special conditions for applying for the permission are not satisfied. See [ohos.permission.LOCATION](../../security/permission-list.md#ohospermissionlocation) and [ohos.permission.APPROXIMATELY_LOCATION](../../security/permission-list.md#ohospermissionapproximately_location).|
18
19## Usage
20
21The permission request result is obtained through an **atManager** instance.
22
23**Example**
24```ts
25import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
26let atManager = abilityAccessCtrl.createAtManager();
27try {
28  atManager.requestPermissionsFromUser(this.context, ["ohos.permission.CAMERA"]).then((data) => {
29      console.info("data:" + JSON.stringify(data));
30      console.info("data permissions:" + data.permissions);
31      console.info("data authResults:" + data.authResults);
32  }).catch((err) => {
33      console.info("data:" + JSON.stringify(err));
34  })
35} catch(err) {
36  console.log(`catch err->${JSON.stringify(err)}`);
37}
38```
39