1e41f4b71Sopenharmony_ci# @ohos.distributedMissionManager (Distributed Mission Management) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **distributedMissionManager** module implements mission management across devices. You can use the APIs provided by this module to register or unregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device by mission ID or bundle name. 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> 9e41f4b71Sopenharmony_ci> The APIs provided by this module are system APIs. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Modules to Import 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```js 14e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## distributedMissionManager.registerMissionListener 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciregisterMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback<void>): void; 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciRegisters a mission status listener. This API uses an asynchronous callback to return the result. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Parameters** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 30e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- | 31e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for.| 32e41f4b71Sopenharmony_ci| options | [MissionCallback](#missioncallback) | Yes | Callback to register.| 33e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the listener is registered, **err** is **undefined**; otherwise, **err** is an error object.| 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Error codes** 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci| ID| Error Message| 40e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 41e41f4b71Sopenharmony_ci| 201 | Permission denied.| 42e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci**Example** 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci ```ts 47e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 48e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci // Implement a callback function. 51e41f4b71Sopenharmony_ci function NotifyMissionsChanged(deviceId: string): void { 52e41f4b71Sopenharmony_ci console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId)); 53e41f4b71Sopenharmony_ci } 54e41f4b71Sopenharmony_ci function NotifySnapshot(deviceId: string, missionId: number): void { 55e41f4b71Sopenharmony_ci console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId)); 56e41f4b71Sopenharmony_ci console.log('NotifySnapshot missionId ' + JSON.stringify(missionId)); 57e41f4b71Sopenharmony_ci } 58e41f4b71Sopenharmony_ci function NotifyNetDisconnect(deviceId: string, state: number): void { 59e41f4b71Sopenharmony_ci console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId)); 60e41f4b71Sopenharmony_ci console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); 61e41f4b71Sopenharmony_ci } 62e41f4b71Sopenharmony_ci try { 63e41f4b71Sopenharmony_ci // Call registerMissionListener. 64e41f4b71Sopenharmony_ci distributedMissionManager.registerMissionListener( 65e41f4b71Sopenharmony_ci { deviceId: "" }, 66e41f4b71Sopenharmony_ci { 67e41f4b71Sopenharmony_ci notifyMissionsChanged: NotifyMissionsChanged, 68e41f4b71Sopenharmony_ci notifySnapshot: NotifySnapshot, 69e41f4b71Sopenharmony_ci notifyNetDisconnect: NotifyNetDisconnect 70e41f4b71Sopenharmony_ci }, 71e41f4b71Sopenharmony_ci (error: BusinessError) => { 72e41f4b71Sopenharmony_ci if (error) { 73e41f4b71Sopenharmony_ci console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); 74e41f4b71Sopenharmony_ci return; 75e41f4b71Sopenharmony_ci } 76e41f4b71Sopenharmony_ci console.info('registerMissionListener finished'); 77e41f4b71Sopenharmony_ci }); 78e41f4b71Sopenharmony_ci } catch (error) { 79e41f4b71Sopenharmony_ci console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); 80e41f4b71Sopenharmony_ci } 81e41f4b71Sopenharmony_ci ``` 82e41f4b71Sopenharmony_ci## distributedMissionManager.registerMissionListener 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ciregisterMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise<void> 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ciRegisters a mission status listener. This API uses a promise to return the result. 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**Parameters** 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 95e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- | 96e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. | 97e41f4b71Sopenharmony_ci| options | <a href="#missioncallback">MissionCallback</a> | Yes | Callback to register.| 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci**Return value** 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci| Type | Description | 102e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 103e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci**Error codes** 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci| ID| Error Message| 110e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 111e41f4b71Sopenharmony_ci| 201 | Permission denied.| 112e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci**Example** 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci ```ts 117e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 118e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci // Implement a callback function. 121e41f4b71Sopenharmony_ci function NotifyMissionsChanged(deviceId: string): void { 122e41f4b71Sopenharmony_ci console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId)); 123e41f4b71Sopenharmony_ci } 124e41f4b71Sopenharmony_ci function NotifySnapshot(deviceId: string, missionId: number): void { 125e41f4b71Sopenharmony_ci console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId)); 126e41f4b71Sopenharmony_ci console.log('NotifySnapshot missionId ' + JSON.stringify(missionId)); 127e41f4b71Sopenharmony_ci } 128e41f4b71Sopenharmony_ci function NotifyNetDisconnect(deviceId: string, state: number): void { 129e41f4b71Sopenharmony_ci console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId)); 130e41f4b71Sopenharmony_ci console.log('NotifyNetDisconnect state ' + JSON.stringify(state)); 131e41f4b71Sopenharmony_ci } 132e41f4b71Sopenharmony_ci try { 133e41f4b71Sopenharmony_ci // Call registerMissionListener. 134e41f4b71Sopenharmony_ci distributedMissionManager.registerMissionListener( 135e41f4b71Sopenharmony_ci { deviceId: "" }, 136e41f4b71Sopenharmony_ci { 137e41f4b71Sopenharmony_ci notifyMissionsChanged: NotifyMissionsChanged, 138e41f4b71Sopenharmony_ci notifySnapshot: NotifySnapshot, 139e41f4b71Sopenharmony_ci notifyNetDisconnect: NotifyNetDisconnect 140e41f4b71Sopenharmony_ci }).then(() => { 141e41f4b71Sopenharmony_ci console.info('registerMissionListener finished. '); 142e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 143e41f4b71Sopenharmony_ci console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); 144e41f4b71Sopenharmony_ci }) 145e41f4b71Sopenharmony_ci } catch (error) { 146e41f4b71Sopenharmony_ci console.error('registerMissionListener failed, cause: ' + JSON.stringify(error)); 147e41f4b71Sopenharmony_ci } 148e41f4b71Sopenharmony_ci ``` 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci## distributedMissionManager.unRegisterMissionListener 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ciunRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ciUnregisters a mission status listener. This API uses an asynchronous callback to return the result. 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ci**Parameters** 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 163e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- | 164e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for. | 165e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the listener is unregistered, **err** is **undefined**; otherwise, **err** is an error object.| 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ci**Error codes** 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci| ID| Error Message| 172e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 173e41f4b71Sopenharmony_ci| 201 | Permission denied.| 174e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**Example** 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci ```ts 179e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 180e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci try { 183e41f4b71Sopenharmony_ci distributedMissionManager.unRegisterMissionListener( 184e41f4b71Sopenharmony_ci { deviceId: "" }, 185e41f4b71Sopenharmony_ci (error: BusinessError) => { 186e41f4b71Sopenharmony_ci if (error) { 187e41f4b71Sopenharmony_ci console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); 188e41f4b71Sopenharmony_ci return; 189e41f4b71Sopenharmony_ci } 190e41f4b71Sopenharmony_ci console.info('unRegisterMissionListener finished'); 191e41f4b71Sopenharmony_ci }) 192e41f4b71Sopenharmony_ci } catch (error) { 193e41f4b71Sopenharmony_ci console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); 194e41f4b71Sopenharmony_ci } 195e41f4b71Sopenharmony_ci ``` 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ci## distributedMissionManager.unRegisterMissionListener 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ciunRegisterMissionListener(parameter: MissionDeviceInfo): Promise<void> 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ciUnregisters a mission status listener. This API uses a promise to return the result. 202e41f4b71Sopenharmony_ci 203e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci**Parameters** 208e41f4b71Sopenharmony_ci 209e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 210e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 211e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Information about the device to listen for.| 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci**Return value** 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci| Type | Description | 216e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 217e41f4b71Sopenharmony_ci| Promise<void> |Promise that returns no value.| 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci**Error codes** 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci| ID| Error Message| 224e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 225e41f4b71Sopenharmony_ci| 201 | Permission denied.| 226e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**Example** 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci ```ts 231e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 232e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci try { 235e41f4b71Sopenharmony_ci distributedMissionManager.unRegisterMissionListener({deviceId: ""}).then(() => { 236e41f4b71Sopenharmony_ci console.info('unRegisterMissionListener finished successfully'); 237e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 238e41f4b71Sopenharmony_ci console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); 239e41f4b71Sopenharmony_ci }) 240e41f4b71Sopenharmony_ci } catch (error) { 241e41f4b71Sopenharmony_ci console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error)); 242e41f4b71Sopenharmony_ci } 243e41f4b71Sopenharmony_ci ``` 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci## distributedMissionManager.startSyncRemoteMissions 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_cistartSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback<void>): void; 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ciStarts to synchronize the remote mission list. This API uses an asynchronous callback to return the result. 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci**Parameters** 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 258e41f4b71Sopenharmony_ci| --------- | ------------------------------------- | ---- | --------- | 259e41f4b71Sopenharmony_ci| parameter | [MissionParameter](#missionparameter) | Yes | Parameters required for synchronization. | 260e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the synchronization is started, **err** is **undefined**; otherwise, **err** is an error object.| 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci**Error codes** 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 265e41f4b71Sopenharmony_ci 266e41f4b71Sopenharmony_ci| ID| Error Message| 267e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 268e41f4b71Sopenharmony_ci| 201 | Permission denied.| 269e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Example** 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci ```ts 274e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 275e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci try { 278e41f4b71Sopenharmony_ci distributedMissionManager.startSyncRemoteMissions( 279e41f4b71Sopenharmony_ci { 280e41f4b71Sopenharmony_ci deviceId: "", 281e41f4b71Sopenharmony_ci fixConflict: false, 282e41f4b71Sopenharmony_ci tag: 0 283e41f4b71Sopenharmony_ci }, 284e41f4b71Sopenharmony_ci (error: BusinessError) => { 285e41f4b71Sopenharmony_ci if (error) { 286e41f4b71Sopenharmony_ci console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 287e41f4b71Sopenharmony_ci return; 288e41f4b71Sopenharmony_ci } 289e41f4b71Sopenharmony_ci console.info('startSyncRemoteMissions finished');} 290e41f4b71Sopenharmony_ci ) 291e41f4b71Sopenharmony_ci } catch (error) { 292e41f4b71Sopenharmony_ci console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 293e41f4b71Sopenharmony_ci } 294e41f4b71Sopenharmony_ci ``` 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci## distributedMissionManager.startSyncRemoteMissions 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_cistartSyncRemoteMissions(parameter: MissionParameter): Promise<void> 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ciStarts to synchronize the remote mission list. This API uses a promise to return the result. 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ci**Parameters** 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 309e41f4b71Sopenharmony_ci| --------- | ------------------------------------- | ---- | ----- | 310e41f4b71Sopenharmony_ci| parameter | [MissionParameter](#missionparameter) | Yes | Parameters required for synchronization.| 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ci**Return value** 313e41f4b71Sopenharmony_ci 314e41f4b71Sopenharmony_ci| Type | Description | 315e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 316e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 317e41f4b71Sopenharmony_ci 318e41f4b71Sopenharmony_ci**Error codes** 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ci| ID| Error Message| 323e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 324e41f4b71Sopenharmony_ci| 201 | Permission denied.| 325e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**Example** 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci ```ts 330e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 331e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 332e41f4b71Sopenharmony_ci 333e41f4b71Sopenharmony_ci try { 334e41f4b71Sopenharmony_ci distributedMissionManager.startSyncRemoteMissions( 335e41f4b71Sopenharmony_ci { 336e41f4b71Sopenharmony_ci deviceId: "", 337e41f4b71Sopenharmony_ci fixConflict: false, 338e41f4b71Sopenharmony_ci tag: 0 339e41f4b71Sopenharmony_ci } 340e41f4b71Sopenharmony_ci ).then(() => { 341e41f4b71Sopenharmony_ci console.info('startSyncRemoteMissions finished successfully'); 342e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 343e41f4b71Sopenharmony_ci console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 344e41f4b71Sopenharmony_ci }) 345e41f4b71Sopenharmony_ci } catch (error) { 346e41f4b71Sopenharmony_ci console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 347e41f4b71Sopenharmony_ci } 348e41f4b71Sopenharmony_ci ``` 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci## distributedMissionManager.stopSyncRemoteMissions 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_cistopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback<void>): void; 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ciStops synchronizing the remote mission list. This API uses an asynchronous callback to return the result. 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci**Parameters** 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 363e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- | 364e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Parameters required for synchronization. | 365e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the synchronization is stopped, **err** is **undefined**; otherwise, **err** is an error object.| 366e41f4b71Sopenharmony_ci 367e41f4b71Sopenharmony_ci**Error codes** 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 370e41f4b71Sopenharmony_ci 371e41f4b71Sopenharmony_ci| ID| Error Message| 372e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 373e41f4b71Sopenharmony_ci| 201 | Permission denied.| 374e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**Example** 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci ```ts 379e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 380e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci try { 383e41f4b71Sopenharmony_ci distributedMissionManager.stopSyncRemoteMissions( 384e41f4b71Sopenharmony_ci { 385e41f4b71Sopenharmony_ci deviceId: "" 386e41f4b71Sopenharmony_ci }, 387e41f4b71Sopenharmony_ci (error: BusinessError) => { 388e41f4b71Sopenharmony_ci if (error) { 389e41f4b71Sopenharmony_ci console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 390e41f4b71Sopenharmony_ci return; 391e41f4b71Sopenharmony_ci } 392e41f4b71Sopenharmony_ci console.info('stopSyncRemoteMissions finished');} 393e41f4b71Sopenharmony_ci ) 394e41f4b71Sopenharmony_ci } catch (error) { 395e41f4b71Sopenharmony_ci console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 396e41f4b71Sopenharmony_ci } 397e41f4b71Sopenharmony_ci ``` 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci## distributedMissionManager.stopSyncRemoteMissions 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_cistopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise<void> 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ciStops synchronizing the remote mission list. This API uses a promise to return the result. 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 406e41f4b71Sopenharmony_ci 407e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci**Parameters** 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 412e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 413e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes | Parameters required for synchronization.| 414e41f4b71Sopenharmony_ci 415e41f4b71Sopenharmony_ci**Return value** 416e41f4b71Sopenharmony_ci 417e41f4b71Sopenharmony_ci| Type | Description | 418e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 419e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ci**Error codes** 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci| ID| Error Message| 426e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 427e41f4b71Sopenharmony_ci| 201 | Permission denied.| 428e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_ci**Example** 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci ```ts 433e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 434e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci try { 437e41f4b71Sopenharmony_ci distributedMissionManager.stopSyncRemoteMissions( 438e41f4b71Sopenharmony_ci { 439e41f4b71Sopenharmony_ci deviceId: "" 440e41f4b71Sopenharmony_ci }).then(() => { 441e41f4b71Sopenharmony_ci console.info('stopSyncRemoteMissions finished successfully'); 442e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 443e41f4b71Sopenharmony_ci console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 444e41f4b71Sopenharmony_ci }) 445e41f4b71Sopenharmony_ci } catch (error) { 446e41f4b71Sopenharmony_ci console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error)); 447e41f4b71Sopenharmony_ci } 448e41f4b71Sopenharmony_ci ``` 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback<void>): void; 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ciContinues a mission on a remote device, with the mission ID specified. This API uses an asynchronous callback to return the result. 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 457e41f4b71Sopenharmony_ci 458e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci**Parameters** 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 463e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 464e41f4b71Sopenharmony_ci| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | Yes | Parameters required for mission continuation.| 465e41f4b71Sopenharmony_ci| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | Yes | Callback invoked when the mission continuation is complete.| 466e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the mission is continued, **err** is **undefined**; otherwise, **err** is an error object.| 467e41f4b71Sopenharmony_ci 468e41f4b71Sopenharmony_ci**Error codes** 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md). 471e41f4b71Sopenharmony_ci 472e41f4b71Sopenharmony_ci| ID| Error Message| 473e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- | 474e41f4b71Sopenharmony_ci| 201 | Permission denied.| 475e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 476e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. | 477e41f4b71Sopenharmony_ci| 16300502 | Failed to get the missionInfo of the specified missionId. | 478e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. | 479e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. | 480e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. | 481e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. | 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci**Example** 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ci ```ts 486e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 487e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ci // Implement a callback function. 490e41f4b71Sopenharmony_ci function onContinueDone(resultCode: number): void { 491e41f4b71Sopenharmony_ci console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode)); 492e41f4b71Sopenharmony_ci }; 493e41f4b71Sopenharmony_ci try { 494e41f4b71Sopenharmony_ci // Call continueMission. 495e41f4b71Sopenharmony_ci distributedMissionManager.continueMission( 496e41f4b71Sopenharmony_ci { 497e41f4b71Sopenharmony_ci srcDeviceId: "", 498e41f4b71Sopenharmony_ci dstDeviceId: "", 499e41f4b71Sopenharmony_ci missionId: 1, 500e41f4b71Sopenharmony_ci wantParam: {"key": "value"} 501e41f4b71Sopenharmony_ci }, 502e41f4b71Sopenharmony_ci { onContinueDone: onContinueDone }, 503e41f4b71Sopenharmony_ci (error: BusinessError) => { 504e41f4b71Sopenharmony_ci if (error) { 505e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 506e41f4b71Sopenharmony_ci return; 507e41f4b71Sopenharmony_ci } 508e41f4b71Sopenharmony_ci console.info('continueMission finished'); 509e41f4b71Sopenharmony_ci }) 510e41f4b71Sopenharmony_ci } catch (error) { 511e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 512e41f4b71Sopenharmony_ci } 513e41f4b71Sopenharmony_ci ``` 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise<void> 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ciContinues a mission on a remote device, with the mission ID specified. This API uses a promise to return the result. 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Parameters** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 528e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 529e41f4b71Sopenharmony_ci| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | Yes | Parameters required for mission continuation.| 530e41f4b71Sopenharmony_ci| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | Yes | Callback invoked when the mission continuation is complete.| 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci**Return value** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ci| Type | Description | 535e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 536e41f4b71Sopenharmony_ci| Promise<void> |Promise that returns no value.| 537e41f4b71Sopenharmony_ci 538e41f4b71Sopenharmony_ci**Error codes** 539e41f4b71Sopenharmony_ci 540e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md). 541e41f4b71Sopenharmony_ci 542e41f4b71Sopenharmony_ci| ID| Error Message| 543e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- | 544e41f4b71Sopenharmony_ci| 201 | Permission denied.| 545e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 546e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. | 547e41f4b71Sopenharmony_ci| 16300502 | Failed to get the missionInfo of the specified missionId. | 548e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. | 549e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. | 550e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. | 551e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. | 552e41f4b71Sopenharmony_ci 553e41f4b71Sopenharmony_ci**Example** 554e41f4b71Sopenharmony_ci 555e41f4b71Sopenharmony_ci ```ts 556e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 557e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci // Implement a callback function. 560e41f4b71Sopenharmony_ci function onContinueDone(resultCode: number): void { 561e41f4b71Sopenharmony_ci console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode)); 562e41f4b71Sopenharmony_ci }; 563e41f4b71Sopenharmony_ci try { 564e41f4b71Sopenharmony_ci // Call continueMission. 565e41f4b71Sopenharmony_ci distributedMissionManager.continueMission( 566e41f4b71Sopenharmony_ci { 567e41f4b71Sopenharmony_ci srcDeviceId: "", 568e41f4b71Sopenharmony_ci dstDeviceId: "", 569e41f4b71Sopenharmony_ci missionId: 1, 570e41f4b71Sopenharmony_ci wantParam: {"key": "value"} 571e41f4b71Sopenharmony_ci }, 572e41f4b71Sopenharmony_ci { onContinueDone: onContinueDone }).then(() => { 573e41f4b71Sopenharmony_ci console.info('continueMission finished successfully'); 574e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 575e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 576e41f4b71Sopenharmony_ci }) 577e41f4b71Sopenharmony_ci } catch (error) { 578e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 579e41f4b71Sopenharmony_ci } 580e41f4b71Sopenharmony_ci ``` 581e41f4b71Sopenharmony_ci 582e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission<sup>10+</sup> 583e41f4b71Sopenharmony_ci 584e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueMissionInfo, callback: AsyncCallback<void>): void; 585e41f4b71Sopenharmony_ci 586e41f4b71Sopenharmony_ciContinues a mission on a remote device, with the bundle name specified. This API uses an asynchronous callback to return the result. 587e41f4b71Sopenharmony_ci 588e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 589e41f4b71Sopenharmony_ci 590e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 591e41f4b71Sopenharmony_ci 592e41f4b71Sopenharmony_ci**Parameters** 593e41f4b71Sopenharmony_ci 594e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 595e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 596e41f4b71Sopenharmony_ci| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | Yes | Parameters required for mission continuation.| 597e41f4b71Sopenharmony_ci| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the mission is continued, **err** is **undefined**; otherwise, **err** is an error object.| 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ci**Error codes** 600e41f4b71Sopenharmony_ci 601e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md). 602e41f4b71Sopenharmony_ci 603e41f4b71Sopenharmony_ci| ID| Error Message| 604e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- | 605e41f4b71Sopenharmony_ci| 201 | Permission denied.| 606e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 607e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. | 608e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. | 609e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. | 610e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. | 611e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. | 612e41f4b71Sopenharmony_ci| 16300507 | Failed to get the missionInfo of the specified bundle name. | 613e41f4b71Sopenharmony_ci 614e41f4b71Sopenharmony_ci**Example** 615e41f4b71Sopenharmony_ci 616e41f4b71Sopenharmony_ci ```ts 617e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 618e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 619e41f4b71Sopenharmony_ci 620e41f4b71Sopenharmony_ci try { 621e41f4b71Sopenharmony_ci distributedMissionManager.continueMission( 622e41f4b71Sopenharmony_ci { 623e41f4b71Sopenharmony_ci srcDeviceId: "", 624e41f4b71Sopenharmony_ci dstDeviceId: "", 625e41f4b71Sopenharmony_ci bundleName: "ohos.test.continueapp", 626e41f4b71Sopenharmony_ci wantParam: {"key": "value"} 627e41f4b71Sopenharmony_ci }, 628e41f4b71Sopenharmony_ci (error: BusinessError) => { 629e41f4b71Sopenharmony_ci if (error) { 630e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 631e41f4b71Sopenharmony_ci return; 632e41f4b71Sopenharmony_ci } 633e41f4b71Sopenharmony_ci console.info('continueMission finished'); 634e41f4b71Sopenharmony_ci }) 635e41f4b71Sopenharmony_ci } catch (error) { 636e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 637e41f4b71Sopenharmony_ci } 638e41f4b71Sopenharmony_ci ``` 639e41f4b71Sopenharmony_ci 640e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission<sup>10+</sup> 641e41f4b71Sopenharmony_ci 642e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueMissionInfo): Promise<void> 643e41f4b71Sopenharmony_ci 644e41f4b71Sopenharmony_ciContinues a mission on a remote device, with the bundle name specified. This API uses a promise to return the result. 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC 647e41f4b71Sopenharmony_ci 648e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 649e41f4b71Sopenharmony_ci 650e41f4b71Sopenharmony_ci**Parameters** 651e41f4b71Sopenharmony_ci 652e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 653e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- | 654e41f4b71Sopenharmony_ci| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | Yes | Parameters required for mission continuation.| 655e41f4b71Sopenharmony_ci 656e41f4b71Sopenharmony_ci**Return value** 657e41f4b71Sopenharmony_ci 658e41f4b71Sopenharmony_ci| Type | Description | 659e41f4b71Sopenharmony_ci| ------------------- | ---------------- | 660e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value.| 661e41f4b71Sopenharmony_ci 662e41f4b71Sopenharmony_ci**Error codes** 663e41f4b71Sopenharmony_ci 664e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md). 665e41f4b71Sopenharmony_ci 666e41f4b71Sopenharmony_ci| ID| Error Message| 667e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- | 668e41f4b71Sopenharmony_ci| 201 | Permission denied.| 669e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 670e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. | 671e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. | 672e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. | 673e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. | 674e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. | 675e41f4b71Sopenharmony_ci| 16300507 | Failed to get the missionInfo of the specified bundle name. | 676e41f4b71Sopenharmony_ci 677e41f4b71Sopenharmony_ci**Example** 678e41f4b71Sopenharmony_ci 679e41f4b71Sopenharmony_ci ```ts 680e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 681e41f4b71Sopenharmony_ci import { BusinessError } from '@kit.BasicServicesKit'; 682e41f4b71Sopenharmony_ci 683e41f4b71Sopenharmony_ci try { 684e41f4b71Sopenharmony_ci distributedMissionManager.continueMission( 685e41f4b71Sopenharmony_ci { 686e41f4b71Sopenharmony_ci srcDeviceId: "", 687e41f4b71Sopenharmony_ci dstDeviceId: "", 688e41f4b71Sopenharmony_ci bundleName: "ohos.test.continueapp", 689e41f4b71Sopenharmony_ci wantParam: {"key": "value"} 690e41f4b71Sopenharmony_ci } 691e41f4b71Sopenharmony_ci ).then(() => { 692e41f4b71Sopenharmony_ci console.info('continueMission finished successfully'); 693e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 694e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 695e41f4b71Sopenharmony_ci }) 696e41f4b71Sopenharmony_ci } catch (error) { 697e41f4b71Sopenharmony_ci console.error('continueMission failed, cause: ' + JSON.stringify(error)); 698e41f4b71Sopenharmony_ci } 699e41f4b71Sopenharmony_ci ``` 700e41f4b71Sopenharmony_ci 701e41f4b71Sopenharmony_ci## distributedMissionManager.on('continueStateChange')<sup>10+</sup> 702e41f4b71Sopenharmony_ci 703e41f4b71Sopenharmony_cion(type: 'continueStateChange', callback: Callback<ContinueCallbackInfo>): void 704e41f4b71Sopenharmony_ci 705e41f4b71Sopenharmony_ciSubscribes to continuation state change events of the current mission. 706e41f4b71Sopenharmony_ci 707e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 708e41f4b71Sopenharmony_ci 709e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 710e41f4b71Sopenharmony_ci 711e41f4b71Sopenharmony_ci**Parameters** 712e41f4b71Sopenharmony_ci 713e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 714e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- | 715e41f4b71Sopenharmony_ci| type | string | Yes | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission. | 716e41f4b71Sopenharmony_ci| callback | Callback<[ContinueCallbackInfo](#continuecallbackinfo11)> | Yes | Callback used to return the continuation state and information of the current mission. | 717e41f4b71Sopenharmony_ci 718e41f4b71Sopenharmony_ci**Error codes** 719e41f4b71Sopenharmony_ci 720e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 721e41f4b71Sopenharmony_ci 722e41f4b71Sopenharmony_ci| ID| Error Message| 723e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 724e41f4b71Sopenharmony_ci| 201 | Permission denied.| 725e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 726e41f4b71Sopenharmony_ci 727e41f4b71Sopenharmony_ci**Example** 728e41f4b71Sopenharmony_ci 729e41f4b71Sopenharmony_ci```js 730e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 731e41f4b71Sopenharmony_ci 732e41f4b71Sopenharmony_ci try { 733e41f4b71Sopenharmony_ci distributedMissionManager.on('continueStateChange', (data) => { 734e41f4b71Sopenharmony_ci console.info("continueStateChange on:" + JSON.stringify(data)); 735e41f4b71Sopenharmony_ci }); 736e41f4b71Sopenharmony_ci } catch (error) { 737e41f4b71Sopenharmony_ci console.error("continueStateChange err: " + JSON.stringify(error)); 738e41f4b71Sopenharmony_ci } 739e41f4b71Sopenharmony_ci ``` 740e41f4b71Sopenharmony_ci 741e41f4b71Sopenharmony_ci## distributedMissionManager.off('continueStateChange')<sup>10+</sup> 742e41f4b71Sopenharmony_ci 743e41f4b71Sopenharmony_cioff(type: 'continueStateChange', callback?: Callback<ContinueCallbackInfo>): void 744e41f4b71Sopenharmony_ci 745e41f4b71Sopenharmony_ciUnsubscribes from continuation state change events of the current mission. 746e41f4b71Sopenharmony_ci 747e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 748e41f4b71Sopenharmony_ci 749e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 750e41f4b71Sopenharmony_ci 751e41f4b71Sopenharmony_ci**Parameters** 752e41f4b71Sopenharmony_ci 753e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 754e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- | 755e41f4b71Sopenharmony_ci| type | string | Yes | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission. | 756e41f4b71Sopenharmony_ci| callback | Callback<[ContinueCallbackInfo](#continuecallbackinfo11)> | No | Callback used for unsubscription.<br>If the callback is unspecified, all subscriptions to the specified event are canceled. | 757e41f4b71Sopenharmony_ci 758e41f4b71Sopenharmony_ci**Error codes** 759e41f4b71Sopenharmony_ci 760e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 761e41f4b71Sopenharmony_ci 762e41f4b71Sopenharmony_ci| ID| Error Message| 763e41f4b71Sopenharmony_ci| ------- | -------------------------------- | 764e41f4b71Sopenharmony_ci| 201 | Permission denied.| 765e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 766e41f4b71Sopenharmony_ci 767e41f4b71Sopenharmony_ci**Example** 768e41f4b71Sopenharmony_ci 769e41f4b71Sopenharmony_ci```js 770e41f4b71Sopenharmony_ci import { distributedMissionManager } from '@kit.AbilityKit'; 771e41f4b71Sopenharmony_ci 772e41f4b71Sopenharmony_ci try { 773e41f4b71Sopenharmony_ci distributedMissionManager.off('continueStateChange', (data) => { 774e41f4b71Sopenharmony_ci console.info("continueStateChange off:" + JSON.stringify(data)); 775e41f4b71Sopenharmony_ci }); 776e41f4b71Sopenharmony_ci } catch (err) { 777e41f4b71Sopenharmony_ci console.error("continueStateChange err: " + JSON.stringify(err)); 778e41f4b71Sopenharmony_ci } 779e41f4b71Sopenharmony_ci ``` 780e41f4b71Sopenharmony_ci 781e41f4b71Sopenharmony_ci## MissionCallback 782e41f4b71Sopenharmony_ci 783e41f4b71Sopenharmony_ciDefines the callbacks that can be registered as a mission status listener. 784e41f4b71Sopenharmony_ci 785e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 786e41f4b71Sopenharmony_ci 787e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 788e41f4b71Sopenharmony_ci 789e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 790e41f4b71Sopenharmony_ci| --------------------- | -------- | ---- | ---- | ------------------ | 791e41f4b71Sopenharmony_ci| notifyMissionsChanged | function | Yes | No | Callback used to notify the mission change event and return the device ID. | 792e41f4b71Sopenharmony_ci| notifySnapshot | function | Yes | No | Callback used to notify the snapshot change event and return the device ID and mission ID.| 793e41f4b71Sopenharmony_ci| notifyNetDisconnect | function | Yes | No | Callback used to notify the disconnection event and return the device ID and network status.| 794e41f4b71Sopenharmony_ci 795e41f4b71Sopenharmony_ci## MissionParameter 796e41f4b71Sopenharmony_ci 797e41f4b71Sopenharmony_ciDefines the parameters required for mission synchronization. 798e41f4b71Sopenharmony_ci 799e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 800e41f4b71Sopenharmony_ci 801e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 802e41f4b71Sopenharmony_ci 803e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 804e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ---- | ----------- | 805e41f4b71Sopenharmony_ci| deviceId | string | Yes | Yes | Device ID. For details, see [getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync). | 806e41f4b71Sopenharmony_ci| fixConflict | boolean | Yes | Yes | Whether a version conflict occurs.| 807e41f4b71Sopenharmony_ci| tag | number | Yes | Yes | Tag of the mission. | 808e41f4b71Sopenharmony_ci 809e41f4b71Sopenharmony_ci## MissionDeviceInfo 810e41f4b71Sopenharmony_ci 811e41f4b71Sopenharmony_ciDefines the parameters required for registering a listener. 812e41f4b71Sopenharmony_ci 813e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS 814e41f4b71Sopenharmony_ci 815e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 816e41f4b71Sopenharmony_ci 817e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 818e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ------- | 819e41f4b71Sopenharmony_ci| deviceId | string | Yes | Yes | Device ID. For details, see [getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).| 820e41f4b71Sopenharmony_ci 821e41f4b71Sopenharmony_ci## ContinueState<sup>10+</sup> 822e41f4b71Sopenharmony_ci 823e41f4b71Sopenharmony_ciEnumerates the mission continuation states. 824e41f4b71Sopenharmony_ci 825e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 826e41f4b71Sopenharmony_ci 827e41f4b71Sopenharmony_ci| Name | Value | Description | 828e41f4b71Sopenharmony_ci| ------------- | --------- | ------------------------------------------------------------ | 829e41f4b71Sopenharmony_ci| ACTIVE | 0 | Continuation is activated for the current mission. | 830e41f4b71Sopenharmony_ci| INACTIVE | 1 | Continuation is not activated for the current mission. | 831e41f4b71Sopenharmony_ci 832e41f4b71Sopenharmony_ci## ContinueCallbackInfo<sup>11+</sup> 833e41f4b71Sopenharmony_ci 834e41f4b71Sopenharmony_ciDefines the information about the callback that is triggered for mission continuation state changes. 835e41f4b71Sopenharmony_ci 836e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission 837e41f4b71Sopenharmony_ci 838e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 839e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ----------- | 840e41f4b71Sopenharmony_ci| state | [ContinueState](#continuestate10) | Yes | No | Continuation state of the mission.| 841e41f4b71Sopenharmony_ci| info | [ContinuableInfo](./js-apis-inner-application-continuableInfo-sys.md) | Yes | No | Continuation information of the mission.| 842