canRunApplication
Category: Application Control
Namespace: web.app.canRunApplication
Description
Check if the application has permission to run. This verifies that the application is properly licensed or within trial period, and returns false if the trial has expired or license is invalid.
Syntax
const canRun = await web.app.canRunApplication();
Parameters
None
Returns
Promise<boolean> - True if application can run, false if trial expired or license invalid
Example
Simple example
const canRun = await web.app.canRunApplication();
console.log('Can run:', canRun);
Practical example
const canRun = await web.app.canRunApplication();
if (!canRun) {
alert('Trial has expired or license is invalid. Please purchase a license.');
await web.app.close();
}
Advanced example
async function validateStartup() {
const canRun = await web.app.canRunApplication();
if (!canRun) {
const trialInfo = await web.app.trialInfo();
const isLicensed = await web.app.licensed();
let message = 'Application cannot run.\n\n';
if (trialInfo.trialExpired) {
message += `Trial expired on ${trialInfo.expirationDate}.\n`;
message += 'Please purchase a license to continue.';
} else if (!isLicensed) {
message += 'No valid license found.\n';
message += 'Please enter a license key or purchase a license.';
} else {
message += 'License validation failed.\n';
message += 'Please contact support.';
}
alert(message);
await web.app.close();
return false;
}
return true;
}
// Call at startup
window.addEventListener('DOMContentLoaded', async () => {
const canStart = await validateStartup();
if (canStart) {
initializeApplication();
}
});
Use Cases
- Validate at application startup
- Check before critical operations
- Enforce trial expiration
- Validate license status
- Prevent unauthorized use
- Startup permission check
- License enforcement
- Trial period validation
Error Handling
This method does not throw errors. Always returns a boolean value.
const canRun = await web.app.canRunApplication();
if (!canRun) {
console.error('Application cannot run - trial expired or invalid license');
await web.app.close();
}
Performance Tips
- Check once at startup
- Cache result for session
- Use for critical validation
- Combine with trial/license info for details
Related Methods
web.app.licensed()- Check if licensedweb.app.trialInfo()- Get trial detailsweb.app.licenseInfo()- Get license detailsweb.app.close()- Close if cannot run
Notes
- Returns false if trial expired
- Returns false if license invalid
- Returns true for valid license or active trial
- Use at startup to enforce licensing
- Prevents running expired trials
- Combine with detailed checks for user feedback