App Metadata

View your User's App Metadata to Suggest Updates

The Despia App Version Check SDK enables your application to retrieve and verify the current app version and bundle numbers. This powerful tool helps maintain your app by enforcing updates, checking compatibility, managing features, supporting rollouts, and improving security.

Quick Start

1. Get Version Information

Request the app version and bundle information using the Despia SDK:

window.despia = "getappversion://"

2. Access Version Values

After calling the command, the version and bundle numbers are available as variables:

console.log("Version:", versionNumber)
console.log("Bundle:", bundleNumber)

3. Handle Version Data

Use the version information to implement your version-dependent logic:

// Example usage
window.despia = "getappversion://"

console.log("Version:", versionNumber);
console.log("Bundle:", bundleNumber);

// Process version data

// EXAMPLES FOR NO-CODE/LOW-CODE TOOLS

// ---------- WEWEB ----------
// WEWEB example using wwWorkflow to handle version data
// 1. Create a Native WeWeb Global Workflow to receive version data
// 2. Add Logic to that Workflow to process the version as needed
// 3. Call your Workflow from exactly this line of code here:
wwLib.wwWorkflow.executeGlobal('YOUR WEWEB WORKFLOW ID', {
    version: versionNumber,
    bundle: bundleNumber
});

// ---------- WIZED ----------
// WIZED example using Wized's JS API
v.versionData = {
    version: versionNumber,
    bundle: bundleNumber
};

// Create a request (API Call) that will send version to your server
const result = await Wized.requests.execute('REQUEST NAME TO PROCESS VERSION');
console.log(result); // Or set result as variable if needed

// ---------- NORDCRAFT / TODDLE ----------
// For Nordcraft / Toddle - simply install the "Despia" Package and listen for the event callback.
// Clone the package from here: https://toddle.dev/projects/despia_package/branches/main
ctx.triggerActionEvent("onVersionCheck", {
    version: versionNumber,
    bundle: bundleNumber
});

How It Works

Version Request:

  • The SDK retrieves the current version and bundle information from the device

  • This information is made immediately available as variables in your app

  • No permissions are required from the user

Version Checking:

  • Your code can compare the retrieved version against minimum requirements

  • This allows for conditional logic based on installed app version

  • Use proper version comparison to handle semantic versioning correctly

Data Handling:

  • Version data can be used directly in your application logic

  • It can be sent to your server for tracking or feature management

  • No-code tools can use workflows to process version information

Version Data Structure

The version check provides two key variables:

{
  versionNumber: "2.0.0",
  bundleNumber: "123"
}

Best Practices

Version Management

  • Always use proper semantic version comparison (2.10.0 is newer than 2.9.0)

  • Plan for handling outdated app versions

  • Consider both critical and optional updates

Error Handling

  • Check that version values are available before using them

  • Have fallback behavior if version check fails

  • Log version information for debugging

Performance

  • Check version at app startup

  • Cache version results when appropriate

  • Don't check unnecessarily on every screen

Complete Implementation Example

Here's a complete implementation that includes version checking and update prompting:

// Function to compare semantic versions
function compareVersions(v1, v2) {
    const parts1 = v1.split('.');
    const parts2 = v2.split('.');
    
    for (let i = 0; i < parts1.length || i < parts2.length; i++) {
        const a = parseInt(parts1[i]) || 0;
        const b = parseInt(parts2[i]) || 0;
        if (a < b) return -1;
        if (a > b) return 1;
    }
    return 0;
}

// Get app version information
window.despia = "getappversion://"

// Check if update is needed
function checkVersion() {
    const minVersion = "2.0.0";
    const criticalVersion = "1.5.0";
    
    if (compareVersions(versionNumber, minVersion) < 0) {
        if (compareVersions(versionNumber, criticalVersion) < 0) {
            showForcedUpdateScreen();
        } else {
            showUpdatePrompt();
        }
    } else {
        console.log("App is up to date");
    }
}

// Call the version check
checkVersion();

Troubleshooting

Common Issues

Version Not Available

  • Make sure getappversion:// is spelled correctly

  • Verify the SDK is properly integrated in your app

  • Check that your code waits for the values to be available

Incorrect Version Comparison

  • Don't use string comparison directly (e.g., versionNumber < "2.0.0")

  • Use a proper version comparison function for semantic versions

  • Test your logic with various version numbers

No-Code Integration Issues

  • Verify workflow and action names are correct

  • Check that version data is being properly passed to your workflows

  • Ensure your no-code platform is set up correctly

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on