Run JavaScript
Extend the capabilities of your SOTI Snap app with custom actions. Use the Run JavaScript action to add custom JavaScript code to your app and define entirely new and complex actions for events.
Run JavaScript actions are added to SOTI Snap apps in the same way as any other action: on a widget, add an event and then select Run JavaScript from the Actions dropdown list. Then, you can paste in valid, well-formed JavaScript code or edit code directly in the Script Editor.
Learn more at Run Blockly.
SOTI Snap validates your JavaScript as you type. Click the warning or error messages on the left of the script editor to see the issues. Although SOTI Snap lets you save invalid JavaScript code, the script will not work in the app.
JavaScript APIs
You can augment your custom JavaScript actions by embedding SOTI Snap objects and functions directly within your scripts. While in the JavaScript text editor, type Snap.
(capital 'S', period included) and then hold down Control + Space to trigger a list of SOTI Snap APIs.
You can also use native JavaScript DOM APIs or jQuery-based APIs to interact with SOTI Snap widgets, but wherever possible, we recommend you use SOTI Snap JavaScript APIs instead.
Device properties
You can target specific device properties in your JavaScript. The SOTI Snap agent leverages an Apache Cordova plugin to expose the following device properties for manipulation:
device.cordova
device.model
device.platform
device.uuid
device.version
device.manufacturer
device.isVirtual
device.serial
Learn more about platform differences and other considerations at Apache Cordova Device Plugin API.