1e41f4b71Sopenharmony_ci# @ohos.application.missionManager (missionManager) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.missionManager](js-apis-app-ability-missionManager-sys.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module are system APIs and cannot be called by third-party applications. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```ts 14e41f4b71Sopenharmony_ciimport missionManager from '@ohos.application.missionManager'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## Required Permissions 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciohos.permission.MANAGE_MISSIONS 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## missionManager.registerMissionListener 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciregisterMissionListener(listener: MissionListener): number 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciRegisters a listener to observe the mission status. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**System API**: This is a system API. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Parameters** 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 36e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 37e41f4b71Sopenharmony_ci | listener | [MissionListener](js-apis-inner-application-missionListener-sys.md) | Yes| Mission status listener to register.| 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Return value** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci | Type| Description| 42e41f4b71Sopenharmony_ci | -------- | -------- | 43e41f4b71Sopenharmony_ci | number | Index of the mission status listener, which is created by the system and allocated when the listener is registered.| 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci**Example** 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci```ts 48e41f4b71Sopenharmony_ciimport missionManager from '@ohos.application.missionManager'; 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ciconsole.log('registerMissionListener'); 51e41f4b71Sopenharmony_cilet listenerid = missionManager.registerMissionListener({ 52e41f4b71Sopenharmony_ci onMissionCreated: (mission) => {console.log('--------onMissionCreated-------');}, 53e41f4b71Sopenharmony_ci onMissionDestroyed: (mission) => {console.log('--------onMissionDestroyed-------');}, 54e41f4b71Sopenharmony_ci onMissionSnapshotChanged: (mission) => {console.log('--------onMissionSnapshotChanged-------');}, 55e41f4b71Sopenharmony_ci onMissionMovedToFront: (mission) => {console.log('--------onMissionMovedToFront-------');}, 56e41f4b71Sopenharmony_ci onMissionIconUpdated: (mission, icon) => {console.log('--------onMissionIconUpdated-------');}, 57e41f4b71Sopenharmony_ci onMissionClosed: (mission) => {console.log('--------onMissionClosed-------');}, 58e41f4b71Sopenharmony_ci onMissionLabelUpdated: (mission) => {console.log('--------onMissionLabelUpdated-------');} 59e41f4b71Sopenharmony_ci}); 60e41f4b71Sopenharmony_ci``` 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci## missionManager.unregisterMissionListener 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ciunregisterMissionListener(listenerId: number, callback: AsyncCallback<void>): void 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ciDeregisters a mission status listener. This API uses an asynchronous callback to return the result. 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci**System API**: This is a system API. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci**Parameters** 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 78e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 79e41f4b71Sopenharmony_ci | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **registerMissionListener()**.| 80e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result.| 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Example** 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci```ts 85e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci console.log('registerMissionListener'); 88e41f4b71Sopenharmony_ci let listenerid = missionManager.registerMissionListener({ 89e41f4b71Sopenharmony_ci onMissionCreated: (mission) => {console.log('--------onMissionCreated-------');}, 90e41f4b71Sopenharmony_ci onMissionDestroyed: (mission) => {console.log('--------onMissionDestroyed-------');}, 91e41f4b71Sopenharmony_ci onMissionSnapshotChanged: (mission) => {console.log('--------onMissionSnapshotChanged-------');}, 92e41f4b71Sopenharmony_ci onMissionMovedToFront: (mission) => {console.log('--------onMissionMovedToFront-------');}, 93e41f4b71Sopenharmony_ci onMissionIconUpdated: (mission, icon) => {console.log('--------onMissionIconUpdated-------');}, 94e41f4b71Sopenharmony_ci onMissionClosed: (mission) => {console.log('--------onMissionClosed-------');}, 95e41f4b71Sopenharmony_ci onMissionLabelUpdated: (mission) => {console.log('--------onMissionLabelUpdated-------');} 96e41f4b71Sopenharmony_ci }); 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci missionManager.unregisterMissionListener(listenerid, (error) => { 99e41f4b71Sopenharmony_ci console.error('unregisterMissionListener fail, error: ${error}'); 100e41f4b71Sopenharmony_ci }); 101e41f4b71Sopenharmony_ci``` 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci## missionManager.unregisterMissionListener 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ciunregisterMissionListener(listenerId: number): Promise<void> 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ciUnregisters a mission status listener. This API uses a promise to return the result. 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**System API**: This is a system API. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**Parameters** 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 119e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 120e41f4b71Sopenharmony_ci | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **registerMissionListener()**.| 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci**Return value** 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci | Type| Description| 125e41f4b71Sopenharmony_ci | -------- | -------- | 126e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**Example** 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci```ts 131e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 132e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_ci console.log('registerMissionListener'); 135e41f4b71Sopenharmony_ci let listenerid = missionManager.registerMissionListener({ 136e41f4b71Sopenharmony_ci onMissionCreated: (mission) => {console.log('--------onMissionCreated-------');}, 137e41f4b71Sopenharmony_ci onMissionDestroyed: (mission) => {console.log('--------onMissionDestroyed-------');}, 138e41f4b71Sopenharmony_ci onMissionSnapshotChanged: (mission) => {console.log('--------onMissionSnapshotChanged-------');}, 139e41f4b71Sopenharmony_ci onMissionMovedToFront: (mission) => {console.log('--------onMissionMovedToFront-------');}, 140e41f4b71Sopenharmony_ci onMissionIconUpdated: (mission, icon) => {console.log('--------onMissionIconUpdated-------');}, 141e41f4b71Sopenharmony_ci onMissionClosed: (mission) => {console.log('--------onMissionClosed-------');}, 142e41f4b71Sopenharmony_ci onMissionLabelUpdated: (mission) => {console.log('--------onMissionLabelUpdated-------');} 143e41f4b71Sopenharmony_ci }); 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci missionManager.unregisterMissionListener(listenerid).catch((error: BusinessError) => { 146e41f4b71Sopenharmony_ci console.error('unregisterMissionListener fail, error: ${error}'); 147e41f4b71Sopenharmony_ci }); 148e41f4b71Sopenharmony_ci``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci## missionManager.getMissionInfo 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_cigetMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ciObtains the information about a given mission. This API uses an asynchronous callback to return the result. 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci**System API**: This is a system API. 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci**Parameters** 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 166e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 167e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 168e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 169e41f4b71Sopenharmony_ci | callback | AsyncCallback<[MissionInfo](js-apis-inner-application-missionInfo-sys.md)> | Yes| Callback used to return the mission information obtained.| 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci**Example** 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci ```ts 174e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci let missionId: number = 0; 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci missionManager.getMissionInfo('', missionId, (error, mission) => { 179e41f4b71Sopenharmony_ci if (error.code) { 180e41f4b71Sopenharmony_ci console.error(`getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}`); 181e41f4b71Sopenharmony_ci return; 182e41f4b71Sopenharmony_ci } 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci console.log(`mission.missionId = ${mission.missionId}`); 185e41f4b71Sopenharmony_ci console.log(`mission.runningState = ${mission.runningState}`); 186e41f4b71Sopenharmony_ci console.log(`mission.lockedState = ${mission.lockedState}`); 187e41f4b71Sopenharmony_ci console.log(`mission.timestamp = ${mission.timestamp}`); 188e41f4b71Sopenharmony_ci console.log(`mission.label = ${mission.label}`); 189e41f4b71Sopenharmony_ci console.log(`mission.iconPath = ${mission.iconPath}`); 190e41f4b71Sopenharmony_ci }); 191e41f4b71Sopenharmony_ci ``` 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci## missionManager.getMissionInfo 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_cigetMissionInfo(deviceId: string, missionId: number): Promise<MissionInfo> 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ciObtains the information about a given mission. This API uses a promise to return the result. 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**System API**: This is a system API. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**Parameters** 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 209e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 210e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 211e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci**Return value** 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci | Type| Description| 216e41f4b71Sopenharmony_ci | -------- | -------- | 217e41f4b71Sopenharmony_ci | Promise<[MissionInfo](js-apis-inner-application-missionInfo-sys.md)> | Promise used to return the mission information obtained.| 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci**Example** 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci ```ts 222e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 223e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci let testMissionId = 1; 226e41f4b71Sopenharmony_citry { 227e41f4b71Sopenharmony_ci missionManager.getMissionInfo('', testMissionId).then((data) => { 228e41f4b71Sopenharmony_ci console.info(`getMissionInfo successfully. Data: ${JSON.stringify(data)}`); 229e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 230e41f4b71Sopenharmony_ci console.error(`getMissionInfo failed. Cause: ${error.message}`); 231e41f4b71Sopenharmony_ci }); 232e41f4b71Sopenharmony_ci} catch (error) { 233e41f4b71Sopenharmony_ci console.error(`getMissionInfo failed. Cause: ${error.message}`); 234e41f4b71Sopenharmony_ci} 235e41f4b71Sopenharmony_ci ``` 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci## missionManager.getMissionInfos 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_cigetMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback<Array<MissionInfo>>): void 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ciObtains information about all missions. This API uses an asynchronous callback to return the result. 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci**System API**: This is a system API. 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci**Parameters** 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 253e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 254e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 255e41f4b71Sopenharmony_ci | numMax | number | Yes| Maximum number of missions whose information can be obtained.| 256e41f4b71Sopenharmony_ci | callback | AsyncCallback<Array<[MissionInfo](js-apis-inner-application-missionInfo-sys.md)>> | Yes| Callback used to return the array of mission information obtained.| 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci**Example** 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci ```ts 261e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci missionManager.getMissionInfos('', 10, (error, missions) => { 264e41f4b71Sopenharmony_ci if (error.code) { 265e41f4b71Sopenharmony_ci console.error(`getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}`); 266e41f4b71Sopenharmony_ci return; 267e41f4b71Sopenharmony_ci } 268e41f4b71Sopenharmony_ci console.log(`size = ${missions.length}`); 269e41f4b71Sopenharmony_ci console.log(`missions = ${JSON.stringify(missions)}`); 270e41f4b71Sopenharmony_ci }); 271e41f4b71Sopenharmony_ci ``` 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci## missionManager.getMissionInfos 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_cigetMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>> 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ciObtains information about all missions. This API uses a promise to return the result. 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 283e41f4b71Sopenharmony_ci 284e41f4b71Sopenharmony_ci**System API**: This is a system API. 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci**Parameters** 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 289e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 290e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 291e41f4b71Sopenharmony_ci | numMax | number | Yes| Maximum number of missions whose information can be obtained.| 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci**Return value** 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ci | Type| Description| 296e41f4b71Sopenharmony_ci | -------- | -------- | 297e41f4b71Sopenharmony_ci | Promise<Array<[MissionInfo](js-apis-inner-application-missionInfo-sys.md)>> | Promise used to return the array of mission information obtained.| 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ci**Example** 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci ```ts 302e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 303e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci try { 306e41f4b71Sopenharmony_ci missionManager.getMissionInfos('', 10).then((data) => { 307e41f4b71Sopenharmony_ci console.info(`getMissionInfos successfully. Data: ${JSON.stringify(data)}`); 308e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 309e41f4b71Sopenharmony_ci console.error(`getMissionInfos failed. Cause: ${error.message}`); 310e41f4b71Sopenharmony_ci }); 311e41f4b71Sopenharmony_ci} catch (error) { 312e41f4b71Sopenharmony_ci console.error(`getMissionInfos failed. Cause: ${error.message}`); 313e41f4b71Sopenharmony_ci} 314e41f4b71Sopenharmony_ci ``` 315e41f4b71Sopenharmony_ci 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci## missionManager.getMissionSnapShot 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_cigetMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback<MissionSnapshot>): void 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ciObtains the snapshot of a given mission. This API uses an asynchronous callback to return the result. 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**System API**: This is a system API. 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci**Parameters** 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 332e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 333e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 334e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 335e41f4b71Sopenharmony_ci | callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)> | Yes| Callback used to return the snapshot information obtained.| 336e41f4b71Sopenharmony_ci 337e41f4b71Sopenharmony_ci**Example** 338e41f4b71Sopenharmony_ci 339e41f4b71Sopenharmony_ci ```ts 340e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci let testMissionId = 2; 343e41f4b71Sopenharmony_citry { 344e41f4b71Sopenharmony_ci missionManager.getMissionSnapShot('', testMissionId, (err, data) => { 345e41f4b71Sopenharmony_ci if (err) { 346e41f4b71Sopenharmony_ci console.error(`getMissionSnapShot failed: ${err.message}`); 347e41f4b71Sopenharmony_ci } else { 348e41f4b71Sopenharmony_ci console.info(`getMissionSnapShot successfully: ${JSON.stringify(data)}`); 349e41f4b71Sopenharmony_ci } 350e41f4b71Sopenharmony_ci }); 351e41f4b71Sopenharmony_ci} catch (err) { 352e41f4b71Sopenharmony_ci console.error(`getMissionSnapShot failed: ${err.message}`); 353e41f4b71Sopenharmony_ci} 354e41f4b71Sopenharmony_ci ``` 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci## missionManager.getMissionSnapShot 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_cigetMissionSnapShot(deviceId: string, missionId: number): Promise<MissionSnapshot> 360e41f4b71Sopenharmony_ci 361e41f4b71Sopenharmony_ciObtains the snapshot of a given mission. This API uses a promise to return the result. 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 364e41f4b71Sopenharmony_ci 365e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci**System API**: This is a system API. 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci**Parameters** 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 372e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 373e41f4b71Sopenharmony_ci | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| 374e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**Return value** 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci | Type| Description| 379e41f4b71Sopenharmony_ci | -------- | -------- | 380e41f4b71Sopenharmony_ci | Promise<[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)> | Promise used to return the snapshot information obtained.| 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci**Example** 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci ```ts 385e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 386e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci let testMissionId = 2; 389e41f4b71Sopenharmony_citry { 390e41f4b71Sopenharmony_ci missionManager.getMissionSnapShot('', testMissionId).then((data) => { 391e41f4b71Sopenharmony_ci console.info(`getMissionSnapShot successfully. Data: ${JSON.stringify(data)}`); 392e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 393e41f4b71Sopenharmony_ci console.error(`getMissionSnapShot failed. Cause: ${error.message}`); 394e41f4b71Sopenharmony_ci }); 395e41f4b71Sopenharmony_ci} catch (error) { 396e41f4b71Sopenharmony_ci console.error(`getMissionSnapShot failed. Cause: ${error.message}`); 397e41f4b71Sopenharmony_ci} 398e41f4b71Sopenharmony_ci ``` 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci## missionManager.lockMission 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_cilockMission(missionId: number, callback: AsyncCallback<void>): void 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ciLocks a given mission. This API uses an asynchronous callback to return the result. 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_ci**System API**: This is a system API. 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci**Parameters** 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 415e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 416e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 417e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the mission is locked, **err** is **undefined**. Otherwise, **err** is an error object.| 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ci**Example** 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ci ```ts 422e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 423e41f4b71Sopenharmony_ci 424e41f4b71Sopenharmony_ci let testMissionId = 2; 425e41f4b71Sopenharmony_citry { 426e41f4b71Sopenharmony_ci missionManager.lockMission(testMissionId, (err, data) => { 427e41f4b71Sopenharmony_ci if (err) { 428e41f4b71Sopenharmony_ci console.error(`lockMission failed: ${err.message}`); 429e41f4b71Sopenharmony_ci } else { 430e41f4b71Sopenharmony_ci console.info(`lockMission successfully: ${JSON.stringify(data)}`); 431e41f4b71Sopenharmony_ci } 432e41f4b71Sopenharmony_ci }); 433e41f4b71Sopenharmony_ci} catch (err) { 434e41f4b71Sopenharmony_ci console.error(`lockMission failed: ${err.message}`); 435e41f4b71Sopenharmony_ci} 436e41f4b71Sopenharmony_ci ``` 437e41f4b71Sopenharmony_ci 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci## missionManager.lockMission 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_cilockMission(missionId: number): Promise<void> 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ciLocks a given mission. This API uses a promise to return the result. 444e41f4b71Sopenharmony_ci 445e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 446e41f4b71Sopenharmony_ci 447e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 448e41f4b71Sopenharmony_ci 449e41f4b71Sopenharmony_ci**System API**: This is a system API. 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ci**Parameters** 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 454e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 455e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 456e41f4b71Sopenharmony_ci 457e41f4b71Sopenharmony_ci**Return value** 458e41f4b71Sopenharmony_ci 459e41f4b71Sopenharmony_ci | Type| Description| 460e41f4b71Sopenharmony_ci | -------- | -------- | 461e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 462e41f4b71Sopenharmony_ci 463e41f4b71Sopenharmony_ci**Example** 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ci ```ts 466e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 467e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci let testMissionId = 2; 470e41f4b71Sopenharmony_citry { 471e41f4b71Sopenharmony_ci missionManager.lockMission(testMissionId).then((data) => { 472e41f4b71Sopenharmony_ci console.info(`lockMission successfully. Data: ${JSON.stringify(data)}`); 473e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 474e41f4b71Sopenharmony_ci console.error(`lockMission failed. Cause: ${error.message}`); 475e41f4b71Sopenharmony_ci }); 476e41f4b71Sopenharmony_ci} catch (error) { 477e41f4b71Sopenharmony_ci console.error(`lockMission failed. Cause: ${error.message}`); 478e41f4b71Sopenharmony_ci} 479e41f4b71Sopenharmony_ci ``` 480e41f4b71Sopenharmony_ci 481e41f4b71Sopenharmony_ci 482e41f4b71Sopenharmony_ci## missionManager.unlockMission 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ciunlockMission(missionId: number, callback: AsyncCallback<void>): void 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ciUnlocks a given mission. This API uses an asynchronous callback to return the result. 487e41f4b71Sopenharmony_ci 488e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**System API**: This is a system API. 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci**Parameters** 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 497e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 498e41f4b71Sopenharmony_ci| missionId | number | Yes| Mission ID.| 499e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the mission is unlocked, **err** is **undefined**. Otherwise, **err** is an error object.| 500e41f4b71Sopenharmony_ci 501e41f4b71Sopenharmony_ci**Example** 502e41f4b71Sopenharmony_ci 503e41f4b71Sopenharmony_ci ```ts 504e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 505e41f4b71Sopenharmony_ci 506e41f4b71Sopenharmony_ci let testMissionId = 2; 507e41f4b71Sopenharmony_citry { 508e41f4b71Sopenharmony_ci missionManager.unlockMission(testMissionId, (err, data) => { 509e41f4b71Sopenharmony_ci if (err) { 510e41f4b71Sopenharmony_ci console.error(`unlockMission failed: ${err.message}`); 511e41f4b71Sopenharmony_ci } else { 512e41f4b71Sopenharmony_ci console.info(`unlockMission successfully: ${JSON.stringify(data)}`); 513e41f4b71Sopenharmony_ci } 514e41f4b71Sopenharmony_ci }); 515e41f4b71Sopenharmony_ci} catch (err) { 516e41f4b71Sopenharmony_ci console.error(`unlockMission failed: ${err.message}`); 517e41f4b71Sopenharmony_ci} 518e41f4b71Sopenharmony_ci ``` 519e41f4b71Sopenharmony_ci 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci## missionManager.unlockMission 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ciunlockMission(missionId: number): Promise<void> 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ciUnlocks a given mission. This API uses a promise to return the result. 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 528e41f4b71Sopenharmony_ci 529e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 530e41f4b71Sopenharmony_ci 531e41f4b71Sopenharmony_ci**System API**: This is a system API. 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci**Parameters** 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 536e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 537e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci**Return value** 540e41f4b71Sopenharmony_ci 541e41f4b71Sopenharmony_ci | Type| Description| 542e41f4b71Sopenharmony_ci | -------- | -------- | 543e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 544e41f4b71Sopenharmony_ci 545e41f4b71Sopenharmony_ci**Example** 546e41f4b71Sopenharmony_ci 547e41f4b71Sopenharmony_ci ```ts 548e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 549e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 550e41f4b71Sopenharmony_ci 551e41f4b71Sopenharmony_ci let testMissionId = 2; 552e41f4b71Sopenharmony_citry { 553e41f4b71Sopenharmony_ci missionManager.unlockMission(testMissionId).then((data) => { 554e41f4b71Sopenharmony_ci console.info(`unlockMission successfully. Data: ${JSON.stringify(data)}`); 555e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 556e41f4b71Sopenharmony_ci console.error(`unlockMission failed. Cause: ${error.message}`); 557e41f4b71Sopenharmony_ci }); 558e41f4b71Sopenharmony_ci} catch (error) { 559e41f4b71Sopenharmony_ci console.error(`unlockMission failed. Cause: ${error.message}`); 560e41f4b71Sopenharmony_ci} 561e41f4b71Sopenharmony_ci ``` 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_ci 564e41f4b71Sopenharmony_ci## missionManager.clearMission 565e41f4b71Sopenharmony_ci 566e41f4b71Sopenharmony_ciclearMission(missionId: number, callback: AsyncCallback<void>): void 567e41f4b71Sopenharmony_ci 568e41f4b71Sopenharmony_ciClears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result. 569e41f4b71Sopenharmony_ci 570e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 571e41f4b71Sopenharmony_ci 572e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 573e41f4b71Sopenharmony_ci 574e41f4b71Sopenharmony_ci**System API**: This is a system API. 575e41f4b71Sopenharmony_ci 576e41f4b71Sopenharmony_ci**Parameters** 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 579e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 580e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 581e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the mission is cleared, **err** is **undefined**. Otherwise, **err** is an error object.| 582e41f4b71Sopenharmony_ci 583e41f4b71Sopenharmony_ci**Example** 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci ```ts 586e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci let testMissionId = 2; 589e41f4b71Sopenharmony_citry { 590e41f4b71Sopenharmony_ci missionManager.clearMission(testMissionId, (err, data) => { 591e41f4b71Sopenharmony_ci if (err) { 592e41f4b71Sopenharmony_ci console.error(`clearMission failed: ${err.message}`); 593e41f4b71Sopenharmony_ci } else { 594e41f4b71Sopenharmony_ci console.info(`clearMission successfully: ${JSON.stringify(data)}`); 595e41f4b71Sopenharmony_ci } 596e41f4b71Sopenharmony_ci }); 597e41f4b71Sopenharmony_ci} catch (err) { 598e41f4b71Sopenharmony_ci console.error(`clearMission failed: ${err.message}`); 599e41f4b71Sopenharmony_ci} 600e41f4b71Sopenharmony_ci ``` 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci 603e41f4b71Sopenharmony_ci## missionManager.clearMission 604e41f4b71Sopenharmony_ci 605e41f4b71Sopenharmony_ciclearMission(missionId: number): Promise<void> 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_ciClears a given mission, regardless of whether it is locked. This API uses a promise to return the result. 608e41f4b71Sopenharmony_ci 609e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 610e41f4b71Sopenharmony_ci 611e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 612e41f4b71Sopenharmony_ci 613e41f4b71Sopenharmony_ci**System API**: This is a system API. 614e41f4b71Sopenharmony_ci 615e41f4b71Sopenharmony_ci**Parameters** 616e41f4b71Sopenharmony_ci 617e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 618e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 619e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 620e41f4b71Sopenharmony_ci 621e41f4b71Sopenharmony_ci**Return value** 622e41f4b71Sopenharmony_ci 623e41f4b71Sopenharmony_ci | Type| Description| 624e41f4b71Sopenharmony_ci | -------- | -------- | 625e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 626e41f4b71Sopenharmony_ci 627e41f4b71Sopenharmony_ci**Example** 628e41f4b71Sopenharmony_ci 629e41f4b71Sopenharmony_ci ```ts 630e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 631e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci let testMissionId = 2; 634e41f4b71Sopenharmony_citry { 635e41f4b71Sopenharmony_ci missionManager.clearMission(testMissionId).then((data) => { 636e41f4b71Sopenharmony_ci console.info(`clearMission successfully. Data: ${JSON.stringify(data)}`); 637e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 638e41f4b71Sopenharmony_ci console.error(`clearMission failed. Cause: ${error.message}`); 639e41f4b71Sopenharmony_ci }); 640e41f4b71Sopenharmony_ci} catch (error) { 641e41f4b71Sopenharmony_ci console.error(`clearMission failed. Cause: ${error.message}`); 642e41f4b71Sopenharmony_ci} 643e41f4b71Sopenharmony_ci ``` 644e41f4b71Sopenharmony_ci 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ci## missionManager.clearAllMissions 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ciclearAllMissions(callback: AsyncCallback<void>): void 649e41f4b71Sopenharmony_ci 650e41f4b71Sopenharmony_ciClears all unlocked missions. This API uses an asynchronous callback to return the result. 651e41f4b71Sopenharmony_ci 652e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 653e41f4b71Sopenharmony_ci 654e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 655e41f4b71Sopenharmony_ci 656e41f4b71Sopenharmony_ci**System API**: This is a system API. 657e41f4b71Sopenharmony_ci 658e41f4b71Sopenharmony_ci**Parameters** 659e41f4b71Sopenharmony_ci 660e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 661e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 662e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result. If all the unlocked missions are cleared, **err** is **undefined**. Otherwise, **err** is an error object.| 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ci**Example** 665e41f4b71Sopenharmony_ci 666e41f4b71Sopenharmony_ci ```ts 667e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager' 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ci try { 670e41f4b71Sopenharmony_ci missionManager.clearAllMissions(err => { 671e41f4b71Sopenharmony_ci if (err) { 672e41f4b71Sopenharmony_ci console.error('clearAllMissions failed: ${err.message}'); 673e41f4b71Sopenharmony_ci } else { 674e41f4b71Sopenharmony_ci console.info('clearAllMissions successfully.'); 675e41f4b71Sopenharmony_ci } 676e41f4b71Sopenharmony_ci }); 677e41f4b71Sopenharmony_ci} catch (err) { 678e41f4b71Sopenharmony_ci console.error('clearAllMissions failed: ${err.message}'); 679e41f4b71Sopenharmony_ci} 680e41f4b71Sopenharmony_ci ``` 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ci## missionManager.clearAllMissions 684e41f4b71Sopenharmony_ci 685e41f4b71Sopenharmony_ciclearAllMissions(): Promise<void> 686e41f4b71Sopenharmony_ci 687e41f4b71Sopenharmony_ciClears all unlocked missions. This API uses a promise to return the result. 688e41f4b71Sopenharmony_ci 689e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 690e41f4b71Sopenharmony_ci 691e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 692e41f4b71Sopenharmony_ci 693e41f4b71Sopenharmony_ci**System API**: This is a system API. 694e41f4b71Sopenharmony_ci 695e41f4b71Sopenharmony_ci**Return value** 696e41f4b71Sopenharmony_ci 697e41f4b71Sopenharmony_ci | Type| Description| 698e41f4b71Sopenharmony_ci | -------- | -------- | 699e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_ci**Example** 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_ci ```ts 704e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 705e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 706e41f4b71Sopenharmony_ci 707e41f4b71Sopenharmony_ci try { 708e41f4b71Sopenharmony_ci missionManager.clearAllMissions().then((data) => { 709e41f4b71Sopenharmony_ci console.info(`clearAllMissions successfully. Data: ${JSON.stringify(data)}`); 710e41f4b71Sopenharmony_ci }).catch((err: BusinessError) => { 711e41f4b71Sopenharmony_ci console.error(`clearAllMissions failed: ${err.message}`); 712e41f4b71Sopenharmony_ci }); 713e41f4b71Sopenharmony_ci} catch (err) { 714e41f4b71Sopenharmony_ci console.error(`clearAllMissions failed: ${err.message}`); 715e41f4b71Sopenharmony_ci} 716e41f4b71Sopenharmony_ci ``` 717e41f4b71Sopenharmony_ci 718e41f4b71Sopenharmony_ci 719e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront 720e41f4b71Sopenharmony_ci 721e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, callback: AsyncCallback<void>): void 722e41f4b71Sopenharmony_ci 723e41f4b71Sopenharmony_ciSwitches a given mission to the foreground. This API uses an asynchronous callback to return the result. 724e41f4b71Sopenharmony_ci 725e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci**System API**: This is a system API. 730e41f4b71Sopenharmony_ci 731e41f4b71Sopenharmony_ci**Parameters** 732e41f4b71Sopenharmony_ci 733e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 734e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 735e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 736e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the mission is switched to the foreground, **err** is **undefined**. Otherwise, **err** is an error object.| 737e41f4b71Sopenharmony_ci 738e41f4b71Sopenharmony_ci**Example** 739e41f4b71Sopenharmony_ci 740e41f4b71Sopenharmony_ci ```ts 741e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_ci let testMissionId = 2; 744e41f4b71Sopenharmony_citry { 745e41f4b71Sopenharmony_ci missionManager.moveMissionToFront(testMissionId, (err, data) => { 746e41f4b71Sopenharmony_ci if (err) { 747e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed: ${err.message}`); 748e41f4b71Sopenharmony_ci } else { 749e41f4b71Sopenharmony_ci console.info(`moveMissionToFront successfully: ${JSON.stringify(data)}`); 750e41f4b71Sopenharmony_ci } 751e41f4b71Sopenharmony_ci }); 752e41f4b71Sopenharmony_ci} catch (err) { 753e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed: ${err.message}`); 754e41f4b71Sopenharmony_ci} 755e41f4b71Sopenharmony_ci ``` 756e41f4b71Sopenharmony_ci 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback<void>): void 761e41f4b71Sopenharmony_ci 762e41f4b71Sopenharmony_ciSwitches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result. 763e41f4b71Sopenharmony_ci 764e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 765e41f4b71Sopenharmony_ci 766e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 767e41f4b71Sopenharmony_ci 768e41f4b71Sopenharmony_ci**System API**: This is a system API. 769e41f4b71Sopenharmony_ci 770e41f4b71Sopenharmony_ci**Parameters** 771e41f4b71Sopenharmony_ci 772e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 773e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 774e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 775e41f4b71Sopenharmony_ci | options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| 776e41f4b71Sopenharmony_ci | callback | AsyncCallback<void> | Yes| Callback used to return the result. If the mission is switched to the foreground, **err** is **undefined**. Otherwise, **err** is an error object.| 777e41f4b71Sopenharmony_ci 778e41f4b71Sopenharmony_ci**Example** 779e41f4b71Sopenharmony_ci 780e41f4b71Sopenharmony_ci ```ts 781e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 782e41f4b71Sopenharmony_ci 783e41f4b71Sopenharmony_ci let testMissionId = 2; 784e41f4b71Sopenharmony_citry { 785e41f4b71Sopenharmony_ci missionManager.moveMissionToFront(testMissionId, {windowMode : 101}, (err, data) => { 786e41f4b71Sopenharmony_ci if (err) { 787e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed: ${err.message}`); 788e41f4b71Sopenharmony_ci } else { 789e41f4b71Sopenharmony_ci console.info(`moveMissionToFront successfully: ${JSON.stringify(data)}`); 790e41f4b71Sopenharmony_ci } 791e41f4b71Sopenharmony_ci }); 792e41f4b71Sopenharmony_ci} catch (err) { 793e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed: ${err.message}`); 794e41f4b71Sopenharmony_ci} 795e41f4b71Sopenharmony_ci ``` 796e41f4b71Sopenharmony_ci 797e41f4b71Sopenharmony_ci 798e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront 799e41f4b71Sopenharmony_ci 800e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, options?: StartOptions): Promise<void> 801e41f4b71Sopenharmony_ci 802e41f4b71Sopenharmony_ciSwitches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result. 803e41f4b71Sopenharmony_ci 804e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 805e41f4b71Sopenharmony_ci 806e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 807e41f4b71Sopenharmony_ci 808e41f4b71Sopenharmony_ci**System API**: This is a system API. 809e41f4b71Sopenharmony_ci 810e41f4b71Sopenharmony_ci**Parameters** 811e41f4b71Sopenharmony_ci 812e41f4b71Sopenharmony_ci | Name| Type| Mandatory| Description| 813e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 814e41f4b71Sopenharmony_ci | missionId | number | Yes| Mission ID.| 815e41f4b71Sopenharmony_ci | options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| 816e41f4b71Sopenharmony_ci 817e41f4b71Sopenharmony_ci**Return value** 818e41f4b71Sopenharmony_ci 819e41f4b71Sopenharmony_ci | Type| Description| 820e41f4b71Sopenharmony_ci | -------- | -------- | 821e41f4b71Sopenharmony_ci | Promise<void> | Promise that returns no value.| 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ci**Example** 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_ci ```ts 826e41f4b71Sopenharmony_ci import missionManager from '@ohos.application.missionManager'; 827e41f4b71Sopenharmony_ci import { BusinessError } from '@ohos.base'; 828e41f4b71Sopenharmony_ci 829e41f4b71Sopenharmony_ci let testMissionId = 2; 830e41f4b71Sopenharmony_citry { 831e41f4b71Sopenharmony_ci missionManager.moveMissionToFront(testMissionId).then((data) => { 832e41f4b71Sopenharmony_ci console.info(`moveMissionToFront successfully. Data: ${JSON.stringify(data)}`); 833e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 834e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed. Cause: ${error.message}`); 835e41f4b71Sopenharmony_ci }); 836e41f4b71Sopenharmony_ci} catch (error) { 837e41f4b71Sopenharmony_ci console.error(`moveMissionToFront failed. Cause: ${error.message}`); 838e41f4b71Sopenharmony_ci} 839e41f4b71Sopenharmony_ci ``` 840