目录

Listening to Multi-Network Concurrency Suggestions (C/C++)

Starting from version 6.0.2(22), this kit supports listening to multi-network concurrency suggestions.

Use Case

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.

API Description

For details about the APIs, please refer to API Reference.

API Description
int32_t HMS_NetworkBoost_RegisterMultiPathRecommendationCallback(HMS_NetworkBoost_OnMultiPathRecommendationcallback, uint32_t *callbackId) Registers the callback for changes on multi-network concurrency suggestions provided by the device.
int32_t HMS_NetworkBoost_UnregisterMultiPathRecommendationCallback(uint32_t callbackId) Deregisters the callback for changes on multi-network concurrency suggestions provided by the device.

Development Procedure

  1. Import the Network Boost Kit module.

    #include "NetworkBoostKit/network_boost_handover.h"
    #include <cstdio>
  2. Add the following library to the CMakeLists.txt file. For details, please refer to Preparations for C API Development.

    libnetwork_boost.so
  3. Call the HMS_NetworkBoost_RegisterMultiPathRecommendationCallback API to register the callback for multi-network concurrency suggestion changes.

    uint32_t callbackId = 0;
    void onMultiPathRecommendationCallback(NetworkBoost_MultiPathRecommendation* recommendation)
    {
        if (recommendation != nullptr) {
            printf("Recommendation type: %d\n", recommendation->action);
        }
        // Callback for multi-network concurrency suggestion changes
    }
    
    int32_t RegisterMultiPathRecommendation()
    {
        // Register a callback and obtain the callback ID. The ID is returned by the system and will be used for subsequent deregistration.
        int32_t ret = HMS_NetworkBoost_RegisterMultiPathRecommendationCallback(onMultiPathRecommendationCallback, &callbackId);
        printf("Result of registering the callback for multi-network concurrency suggestion changes: %d, Id: %d\n", ret, callbackId);
        return ret;
    }
  4. Deregister the callback for multi-network concurrency suggestion changes after your app process ends.

    int32_t UnregisterMultiPathRecommendation() {
        // Deregister the callback using the callback ID obtained during registration.
        int32_t ret = HMS_NetworkBoost_UnregisterMultiPathRecommendationCallback(callbackId);
        printf("Result of deregistering the callback for multi-network concurrency suggestion changes: %d\n", ret);
        return ret;
    }