1# MissionListener 2 3The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [on](js-apis-app-ability-missionManager.md#missionmanageron). 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 9## Modules to Import 10 11```ts 12import missionManager from '@ohos.app.ability.missionManager'; 13``` 14 15## Attributes 16 17**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 18 19**System API**: This is a system API and cannot be called by third-party applications. 20 21| Name | Type | Mandatory| Description | 22| ----------- | -------- | ---- | ------------------------------------------------------------ | 23| onMissionCreated | function | No | Called when the system creates a mission. | 24| onMissionDestroyed | function | No | Called when the system destroys the mission.| 25| onMissionSnapshotChanged | function | No | Called when the system updates the mission snapshot.| 26| onMissionMovedToFront | function | No | Called when the system moves the mission to the foreground.| 27| onMissionLabelUpdated<sup>9+</sup> | function | No | Called when the system updates the mission label.| 28| onMissionIconUpdated<sup>9+</sup> | function | No | Called when the system updates the mission icon.| 29| onMissionClosed<sup>9+</sup> | function | No | Called when the system closes the mission.| 30 31**Example** 32```ts 33import missionManager from '@ohos.app.ability.missionManager'; 34 35let listener: missionManager.MissionListener = { 36 onMissionCreated: (mission) => { 37 console.log(`onMissionCreated mission: ${JSON.stringify(mission)}`); 38 }, 39 onMissionDestroyed: (mission) => { 40 console.log(`onMissionDestroyed mission: ${JSON.stringify(mission)}`); 41 }, 42 onMissionSnapshotChanged: (mission) => { 43 console.log(`onMissionSnapshotChanged mission: ${JSON.stringify(mission)}`); 44 }, 45 onMissionMovedToFront: (mission) => { 46 console.log(`onMissionMovedToFront mission: ${JSON.stringify(mission)}`); 47 }, 48 onMissionLabelUpdated: (mission) => { 49 console.log(`onMissionLabelUpdated mission: ${JSON.stringify(mission)}`); 50 }, 51 onMissionIconUpdated: (mission, icon) => { 52 console.log(`onMissionIconUpdated mission: ${JSON.stringify(mission)}`); 53 console.log(`onMissionIconUpdated icon: ${JSON.stringify(mission)}`); 54 }, 55 onMissionClosed: (mission) => { 56 console.log(`onMissionClosed mission: ${JSON.stringify(mission)}`); 57 } 58}; 59 60try { 61 let listenerId = missionManager.on('mission', listener); 62} catch (paramError) { 63 console.error(`error: ${paramError.code}, ${paramError.message}`); 64} 65``` 66