Skip to content

Dynamic Configuration and Dynamic Update URL

This article describes the proactive update of remote configuration and dynamic update of the upload URL feature in UniApp SDK 0.3.0 and above.

Dynamic Configuration

Proactively Update Remote Configuration

Before calling the uni-app application, you need to set remoteConfiguration: true in sdkConfig; for uni mini programs within a host app, the host app enables remote configuration when initializing the Native SDK. miniUpdateInterval uses the minimum update interval specified in this call.

mobileAgent.updateRemoteConfigWithMiniUpdateInterval({
    miniUpdateInterval: 0
}, result => {
    if (result.success) {
        console.log('remote config: ' + result.rawJson);
    } else {
        console.log('remote config failed: ' + result.errorMessage);
    }
});

API - updateRemoteConfigWithMiniUpdateInterval

Request Field Type Required Description
miniUpdateInterval number No Minimum interval for this proactive update, range [0,), in seconds, default 0

Callback parameters:

Return Field Type Description
success boolean Whether the update succeeded
platform string Current platform
rawJson string The raw remote configuration JSON string returned on successful update
errorCode number/string Error code if the update failed
errorMessage string Error message if the update failed

Dynamic Update Upload URL

During initialization, both datakitUrl and datawayUrl can be omitted. The SDK can still initialize and cache data before a valid upload URL is set; data upload begins after the URL is set. Use either setDatakitURL or setDatawayURL. When switching to DataWay, clientToken must also be provided.

mobileAgent.setDatakitURL({
    datakitUrl: 'http://10.0.0.1:9529'
});

// Use the following method instead of setDatakitURL when using DataWay.
mobileAgent.setDatawayURL({
    datawayUrl: 'https://open.dataway.url',
    clientToken: 'client-token'
});

API - setDatakitURL

Field Type Required Description
datakitUrl string Yes New Datakit upload URL

API - setDatawayURL

Field Type Required Description
datawayUrl string Yes New DataWay upload URL
clientToken string Yes Authentication token matching the DataWay URL

Feedback

Is this page helpful?