System variables reference
  • 18 May 2022
  • 3 Minutes to read
  • Dark
    Light
  • PDF

System variables reference

  • Dark
    Light
  • PDF

System variables are values calculated by the app runtime, covering things like current app version or screen width. They are automatically kept up-to-date, so e.g. resizing your screen will affect systemVars.dimensions.window, and rotating your phone will update systemVars.orientation.

They can be accessed in formula functions under the systemVars namespace. This means that e.g. os below is found under systemVars.os.

System variable Valid values Description
os android, ios, windows_phone, black_berry, androidtv, tvos, tizen, webos, windows, macos, unix, linux, unknown Name of the current operating system.
orientation portait, landscape Device orientation.
dimensions.screen.width Any positive integer value Screen width, in pixels.
dimensions.screen.height Any positive integer value Screen height, in pixels
dimensions.window.width Any positive integer value Window width, in pixels. On mobile, this is equal to screen width.
dimensions.window.height Any positive integer value Window width, in pixels. On mobile, this is equal to screen width.
dimensions.viewport.width Any positive integer value Visible viewport width excluding sidebar if exists.
dimensions.viewport.height Any positive integer value Visible viewport height excluding navbar and topbar if exists.
env dev, prod Current environment. If release management is not in use, the value is always prod.
formFactor phone, tablet, big_screen, desktop, unknown Device form factor.
permissions N/A Covered in the Permissons reference document.
buildVersion Semver version code, e.g. 1.0.5 Binary build version, set in the build configuration.
runtimeVersion Semver version code, e.g. 1.2.4 AppGyver runtime version.
buildType client, selector Build type. selector means the AppGyver app used to view and develop your apps.
networkStatus none, cellurar, wifi, unknown Network status. If there is no network, or the app is running with the web runtime, then none is returned.
runtime web, native Runtime type.
initialUrl String value If your app was launched from external URL that URL is registered intoinitialUrlsystem variable.
uriSchemes.primary String value This variable represent url your app can be launched from external tool i.e. mobile browser.

File system

The systemVars.filesystem object contains information about the file system of the device the app is currently running.

This information is only available on native apps, not when running on web.

Common base directories

The systemVars.filesystem.directories object contains the base directory paths available on the device. Flow functions that deal with files work with absolute paths, so a pattern you will encounter is using these at the beginning of a file path constructed with a formula, e.g. systemVars.filesystem.directories.cache + "/myTempFile.jpg".

The following directories are available on both iOS and Android.

Document

systemVars.fileSystem.directories.document

Local file system path to the document directory. This directory will only be emptied when the app is uninstalled, so it can be used to safely store files your app needs to function.

For example, /data/user/0/com.appgyver.agclient.debug/files.

Under the hood on iOS, the NSDocumentDirectory API is used. On Android, the getDataDirectory API is used.

Cache

systemVars.filesystem.directories.cache

Local file system path to the cache directory for the app. This directory can be emptied by the operating system, so it should only be used to store temporary files.

For example, /data/user/0/com.appgyver.agclient.debug/cache.

On iOS, the NSCachesDirectory is used. On Android, the getCacheDir API is used on the app context.

iOS-only directories

The directories below are only available when the app is running on an iOS device.

Main bundle

systemVars.filesystem.directories.ios.mainBundle

Local file system path to the main bundle directory, which contains files embedded in the iOS binary. This directory is read-only.

Android-only directories

The directories below are only available when the app is running on an Android device.

DCIM

systemVars.filesystem.directories.android.dcim

Local filesystem path to the Digital Camera Images (DCIM) directory.

Download

systemVars.filesystem.directories.android.download

Local filesystem path to the downloads directory.

Music

systemVars.filesystem.directories.android.music

Local filesystem path to the music directory.

Pictures

systemVars.filesystem.directories.android.pictures

Local filesystem path to the pictures directory.

Movies

systemVars.filesystem.directories.android.movies

Local filesystem path to the movies directory.

Ringtones

systemVars.filesystem.directories.android.ringtones

Local filesystem path to the ringtones directory.

SD card

systemVars.filesystem.directories.android.sdCard

Local filesystem path to the device SD card directory.


Was this article helpful?