• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MissionInfo (System API)
2
3The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager-sys.md#missionmanagergetmissioninfo).
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> The APIs provided by this module are system APIs.
9
10## Modules to Import
11
12```ts
13import missionManager from '@ohos.app.ability.missionManager';
14```
15
16## Attributes
17
18**System API**: This is a system API and cannot be called by third-party applications.
19
20**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
21
22| Name| Type| Readable| Writable| Description|
23| -------- | -------- | -------- | -------- | -------- |
24| missionId | number | Yes| Yes| Mission ID.|
25| runningState | number | Yes| Yes| Running state of the mission.|
26| lockedState | boolean | Yes| Yes| Locked state of the mission.|
27| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
28| want | [Want](js-apis-app-ability-want.md) | Yes| Yes| Want information of the mission.|
29| label | string | Yes| Yes| Label of the mission.|
30| iconPath | string | Yes| Yes| Path of the mission icon.|
31| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device.|
32| abilityState<sup>10+</sup> | number | Yes| Yes| Capability status of the mission.|
33| unclearable<sup>10+</sup> | boolean | Yes| Yes| Whether the mission can be manually deleted.|
34
35**Example**
36```ts
37import missionManager from '@ohos.app.ability.missionManager';
38
39try {
40  missionManager.getMissionInfo('', 1, (error, data) => {
41    if (error) {
42        // Process service logic errors.
43        console.error(`getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}`);
44        return;
45    }
46
47    console.log(`getMissionInfo missionId is: ${JSON.stringify(data.missionId)}`);
48    console.log(`getMissionInfo runningState is: ${JSON.stringify(data.runningState)}`);
49    console.log(`getMissionInfo lockedState is: ${JSON.stringify(data.lockedState)}`);
50    console.log(`getMissionInfo timestamp is: ${JSON.stringify(data.timestamp)}`);
51    console.log(`getMissionInfo want is: ${JSON.stringify(data.want)}`);
52    console.log(`getMissionInfo label is: ${JSON.stringify(data.label)}`);
53    console.log(`getMissionInfo iconPath is: ${JSON.stringify(data.iconPath)}`);
54    console.log(`getMissionInfo continuable is: ${JSON.stringify(data.continuable)}`);
55    console.log(`getMissionInfo unclearable is: ${JSON.stringify(data.unclearable)}`);
56    });
57} catch (paramError) {
58    console.error(`error: ${paramError.code}, ${paramError.message}`);
59}
60```
61