Auto-Updates
Your app can detect whether a newer release is available for your product and prompt the user to update, or download the update silently. You can implement the check using either the Web API or LexActivator.
Checking for updates using the Web API
Invoke the /v3/releases/update endpoint to check whether a new release is available by comparing it with the provided release version.
GET https://api.cryptlex.com/v3/releases/updateFor accounts in the EU data region, use https://api.eu.cryptlex.com/v3 as the Web API base URL.
Query parameters
| Name | Type | Description |
|---|---|---|
| productId* | string | Unique identifier for the product |
| platform* | string | Release platform |
| channel | string | Release channel (defaults to "stable") |
| version* | string | Current release version |
| key* | string | License key |
| accountId* | string | Unique identifier for the account |
If an update is available it returns a 200 success response containing the release details along with the download URLs of its files (the same response shape as the latest release endpoint), otherwise it returns a 204 empty response.
Checking for updates using LexActivator
LexActivator provides the CheckReleaseUpdate() function, which performs the same check and invokes your callback with the result. Sample code for all supported languages is available in the LexActivator sample projects on GitHub. The following sample code demonstrates it for C/C++.
void LA_CC SoftwareReleaseUpdateCallback(int status, Release* release, void* custom_data)
{
switch (status)
{
case LA_RELEASE_UPDATE_AVAILABLE:
printf("A new update is available for the app.");
printf("Release notes: %s", release->notes);
break;
case LA_RELEASE_UPDATE_AVAILABLE_NOT_ALLOWED:
printf("A new update is available for the app but it's not allowed.");
printf("Release notes: %s", release->notes);
break;
case LA_RELEASE_UPDATE_NOT_AVAILABLE:
printf("Current version is already latest.");
break;
default:
printf("Error code: %d", status);
}
}
int main()
{
int status;
// init code - SetProductId(), SetProductData()
// Ensure that platform, channel and version actually exist for the release
status = SetReleasePlatform("windows");
if (LA_OK != status)
{
// handle error
}
status = SetReleaseChannel("stable");
if (LA_OK != status)
{
// handle error
}
status = SetReleaseVersion("1.2.3.4");
if (LA_OK != status)
{
// handle error
}
status = CheckReleaseUpdate(SoftwareReleaseUpdateCallback, LA_RELEASES_ALL, NULL);
if (LA_OK != status)
{
printf("Error checking for software release update: %d", status);
}
}Ignoring PATCH and BUILD updates
The version format syntax in Cryptlex is $MAJOR.$MINOR.$PATCH.$BUILD. If you want to ignore $PATCH and $BUILD releases in the update API endpoint, you can pass a partial version.
The following table summarizes the expected response from the /v3/releases/update API endpoint when it is invoked with the version query parameter set to the values in the first column:
| Version (Query Param) | Latest Version | Response (Status Code) |
|---|---|---|
| 1.2.3.5 | 1.2.3.5 | 204 |
| 1.2.3.4 | 1.2.3.5 | 200 |
| 1.2.3 | 1.2.3.4 | 204 |
| 1.2 | 1.2.3.4 | 204 |
For example, if your latest release version is 1.2.3.4 and you invoke the update API endpoint with the version query parameter set to 1.2.3, it returns a 204 status code indicating no update.