Skip to main content

CloudDataManager

Manages persistent cloud data storage for user scripts.

TypeNameInterface Description
Functionsconstructor(schema: {[key: string]: number | string})

Function: Creates a new CloudDataManager with a defined data schema.

Parameters

schema: - An object whose keys define the persisted fields and whose values provide the initial defaults. Only number and string values are supported. Only keys present in this schema will be saved and loaded. The total serialized data must not exceed 1 KB. Example: new CloudDataManager({ score: 0, level: 1, name: '' })

FunctionsgetEffectUsageInfo(): EffectUsageInfo

Function: Returns the current effect's usage statistics. The data is populated by the system after initialization; values may be zero if called before the cloud data has finished loading.

Returns An instance with the latest usage stats.

FunctionsloadData(onSuccess: (data: {[key: string]: number | string}) => void, onFailure?: (error: string) => void): void

Function: Loads data from cloud storage. Waits for the cloud data to be available (fetched from network on mobile, or read from disk in the editor), then returns an object matching the constructor schema structure. Stored values override cached values; keys not yet persisted retain their last known cached value. The internal cache is updated with the loaded values.

Parameters

onSuccess: - Called with the loaded data object. The object contains exactly the keys defined in the constructor schema, with values of type number or string.

onFailure: - Optional. Called with an error message string if the load fails (e.g. network failure or timeout).

FunctionssaveData(data: {[key: string]: number | string}, onSuccess?: () => void, onFailure?: (error: string) => void): void

Function: Saves data to cloud storage. Only keys defined in the constructor schema are persisted; any extra keys in data are ignored. For schema keys not present in data, the last cached value is used. The internal cache is updated with the provided values. Only number and string values are accepted. The total serialized data size must not exceed 1 KB; the save will fail otherwise.

Parameters

data: - An object containing the key-value pairs to save. Keys must match the schema defined in the constructor. Values must be of type number or string.

onSuccess: - Optional. Called when the data has been successfully written to the storage cache (the system syncs it to cloud/disk automatically).

onFailure: - Optional. Called with an error message string if the save fails (e.g. data exceeds 1 KB or contains invalid value types).

Examples

constructor(schema: {[key: string]: number | string})

let obj = new APJS.CloudDataManager();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use CloudDataManager here
}
onUpdate(deltaTime: number) {
}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies