When the device detects that an app may need to use multi-network concurrency for network acceleration in specific scenarios such as weak signal and network handover, it provides relevant suggestions. Your app can listen to these suggestions and decide whether to initiate a multi-network concurrency request.
For details about the APIs, please refer to API Reference.
| API | Description |
|---|---|
| on(type: 'multiPathRecommendation', callback: Callback<MultiPathRecommendationInfo>): void | Subscribes to multi-network concurrency suggestion changes. |
| off(type: 'multiPathRecommendation', callback?: Callback<MultiPathRecommendationInfo>): void | Unsubscribes from multi-network concurrency suggestion changes. |
Import the Network Boost Kit module.
import { netHandover } from '@kit.NetworkBoostKit';
import { BusinessError } from '@kit.BasicServicesKit'; Subscribe to multi-network concurrency suggestion changes.
try {
netHandover.on('multiPathRecommendation', (data: netHandover.MultiPathRecommendationInfo) => {
// Callback information processing.
console.info("on multiPathRecommendation: " + JSON.stringify(data));
});
} catch (err) {
console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
} Unsubscribe from multi-network concurrency suggestion changes after your app process ends.
try {
netHandover.off('multiPathRecommendation');
} catch (err) {
console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
}