1e41f4b71Sopenharmony_ci# MissionCallback (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe MissionCallback module defines the callbacks invoked after synchronization starts. These callbacks can be used as input parameters in [registerMissionListener](js-apis-distributedMissionManager-sys.md#distributedmissionmanagerregistermissionlistener). 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 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. 8e41f4b71Sopenharmony_ci> The APIs provided by this module are system APIs. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Modules to Import 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci```ts 13e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit'; 14e41f4b71Sopenharmony_ci``` 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## MissionCallback.notifyMissionsChanged 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci**System API**: This is a system API. 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci**Parameters** 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci| Name | Template | Mandatory | Description | 25e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 26e41f4b71Sopenharmony_ci| deviceId | string | Yes | Device ID in the callback that notifies a mission change.| 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci**Example** 29e41f4b71Sopenharmony_ci```ts 30e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit'; 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_cidistributedMissionManager.registerMissionListener( 33e41f4b71Sopenharmony_ci { 34e41f4b71Sopenharmony_ci deviceId: '123456' 35e41f4b71Sopenharmony_ci }, 36e41f4b71Sopenharmony_ci { 37e41f4b71Sopenharmony_ci notifyMissionsChanged: (deviceId: string) => { 38e41f4b71Sopenharmony_ci console.log(`notifyMissionsChanged deviceId: ${JSON.stringify(deviceId)}`); 39e41f4b71Sopenharmony_ci }, 40e41f4b71Sopenharmony_ci notifySnapshot: (deviceId: string, mission: number) => { 41e41f4b71Sopenharmony_ci console.log(`notifySnapshot deviceId: ${JSON.stringify(deviceId)}`); 42e41f4b71Sopenharmony_ci console.log(`notifySnapshot mission: ${JSON.stringify(mission)}`); 43e41f4b71Sopenharmony_ci }, 44e41f4b71Sopenharmony_ci notifyNetDisconnect: (deviceId: string, state: number) => { 45e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect deviceId: ${JSON.stringify(deviceId)}`); 46e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect state: ${JSON.stringify(state)}`); 47e41f4b71Sopenharmony_ci } 48e41f4b71Sopenharmony_ci } 49e41f4b71Sopenharmony_ci); 50e41f4b71Sopenharmony_ci``` 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci## MissionCallback.notifySnapshot 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci**System API**: This is a system API. 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**Parameters** 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci| Name | Template | Mandatory | Description | 61e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 62e41f4b71Sopenharmony_ci| deviceId | string | Yes | Device ID in the callback that notifies a snapshot change. | 63e41f4b71Sopenharmony_ci| mission | number | Yes | Mission ID in the callback that notifies a snapshot change. | 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci**Example** 66e41f4b71Sopenharmony_ci```ts 67e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit'; 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_cidistributedMissionManager.registerMissionListener( 70e41f4b71Sopenharmony_ci { 71e41f4b71Sopenharmony_ci deviceId: '123456' 72e41f4b71Sopenharmony_ci }, 73e41f4b71Sopenharmony_ci { 74e41f4b71Sopenharmony_ci notifyMissionsChanged: (deviceId: string) => { 75e41f4b71Sopenharmony_ci console.log(`notifyMissionsChanged deviceId: ${JSON.stringify(deviceId)}`); 76e41f4b71Sopenharmony_ci }, 77e41f4b71Sopenharmony_ci notifySnapshot: (deviceId: string, mission: number) => { 78e41f4b71Sopenharmony_ci console.log(`notifySnapshot deviceId: ${JSON.stringify(deviceId)}`); 79e41f4b71Sopenharmony_ci console.log(`notifySnapshot mission: ${JSON.stringify(mission)}`); 80e41f4b71Sopenharmony_ci }, 81e41f4b71Sopenharmony_ci notifyNetDisconnect: (deviceId: string, state: number) => { 82e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect deviceId: ${JSON.stringify(deviceId)}`); 83e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect state: ${JSON.stringify(state)}`); 84e41f4b71Sopenharmony_ci } 85e41f4b71Sopenharmony_ci } 86e41f4b71Sopenharmony_ci); 87e41f4b71Sopenharmony_ci``` 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci## MissionCallback.notifyNetDisconnect 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**System API**: This is a system API. 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**Parameters** 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci| Name | Template | Mandatory | Description | 98e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 99e41f4b71Sopenharmony_ci| deviceId | string | Yes | Device ID in the callback that notifies disconnection. | 100e41f4b71Sopenharmony_ci| state | number | Yes | Network status in the callback that notifies disconnection. | 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci**Example** 103e41f4b71Sopenharmony_ci```ts 104e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit'; 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_cidistributedMissionManager.registerMissionListener( 107e41f4b71Sopenharmony_ci { 108e41f4b71Sopenharmony_ci deviceId: '123456' 109e41f4b71Sopenharmony_ci }, 110e41f4b71Sopenharmony_ci { 111e41f4b71Sopenharmony_ci notifyMissionsChanged: (deviceId: string) => { 112e41f4b71Sopenharmony_ci console.log(`notifyMissionsChanged deviceId: ${JSON.stringify(deviceId)}`); 113e41f4b71Sopenharmony_ci }, 114e41f4b71Sopenharmony_ci notifySnapshot: (deviceId: string, mission: number) => { 115e41f4b71Sopenharmony_ci console.log(`notifySnapshot deviceId: ${JSON.stringify(deviceId)}`); 116e41f4b71Sopenharmony_ci console.log(`notifySnapshot mission: ${JSON.stringify(mission)}`); 117e41f4b71Sopenharmony_ci }, 118e41f4b71Sopenharmony_ci notifyNetDisconnect: (deviceId: string, state: number) => { 119e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect deviceId: ${JSON.stringify(deviceId)}`); 120e41f4b71Sopenharmony_ci console.log(`notifyNetDisconnect state: ${JSON.stringify(state)}`); 121e41f4b71Sopenharmony_ci } 122e41f4b71Sopenharmony_ci } 123e41f4b71Sopenharmony_ci); 124e41f4b71Sopenharmony_ci``` 125