1# MissionListener (System API) 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-sys.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> 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 | Mandatory| Description | 23| ----------- | -------- | ---- | ------------------------------------------------------------ | 24| onMissionCreated | function | No | Called when the system creates a mission. | 25| onMissionDestroyed | function | No | Called when the system destroys the mission.| 26| onMissionSnapshotChanged | function | No | Called when the system updates the mission snapshot.| 27| onMissionMovedToFront | function | No | Called when the system moves the mission to the foreground.| 28| onMissionLabelUpdated<sup>9+</sup> | function | No | Called when the system updates the mission label.| 29| onMissionIconUpdated<sup>9+</sup> | function | No | Called when the system updates the mission icon.| 30| onMissionClosed<sup>9+</sup> | function | No | Called when the system closes the mission.| 31 32**Example** 33```ts 34import missionManager from '@ohos.app.ability.missionManager'; 35 36let listener: missionManager.MissionListener = { 37 onMissionCreated: (mission) => { 38 console.log(`onMissionCreated mission: ${JSON.stringify(mission)}`); 39 }, 40 onMissionDestroyed: (mission) => { 41 console.log(`onMissionDestroyed mission: ${JSON.stringify(mission)}`); 42 }, 43 onMissionSnapshotChanged: (mission) => { 44 console.log(`onMissionSnapshotChanged mission: ${JSON.stringify(mission)}`); 45 }, 46 onMissionMovedToFront: (mission) => { 47 console.log(`onMissionMovedToFront mission: ${JSON.stringify(mission)}`); 48 }, 49 onMissionLabelUpdated: (mission) => { 50 console.log(`onMissionLabelUpdated mission: ${JSON.stringify(mission)}`); 51 }, 52 onMissionIconUpdated: (mission, icon) => { 53 console.log(`onMissionIconUpdated mission: ${JSON.stringify(mission)}`); 54 console.log(`onMissionIconUpdated icon: ${JSON.stringify(mission)}`); 55 }, 56 onMissionClosed: (mission) => { 57 console.log(`onMissionClosed mission: ${JSON.stringify(mission)}`); 58 } 59}; 60 61try { 62 let listenerId = missionManager.on('mission', listener); 63} catch (paramError) { 64 console.error(`error: ${paramError.code}, ${paramError.message}`); 65} 66``` 67