App

App-level capabilities: lifecycle (quit, launch-at-startup), OS permissions, deeplinks, and auto-updates.

The methods on this page span several namespaces (app, permissions, autoUpdate, deeplink). They're grouped here because they concern the app as a whole rather than any one window.

Methods

Exit App

Force closes all windows and quits the app.

await window.deskifier.app.exit()

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Launch At Startup

Sets whether the app should automatically launch when the user logs in.

await window.deskifier.app.setLaunchAtStartup({ arguments })

Arguments

  • launchAtStartup Boolean (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Example

const result = await window.deskifier.app.setLaunchAtStartup({
    launchAtStartup: true
});

console.log(result.success);  // true

Request Permission

macOS Request use of a certain media type.

Usually, permissions can only be asked once. It's recommended to prompt users with your own UI letting them know to accept the request.

This feature is only available on macOS. Generally, other platforms will have permissions by default.

If needed, you can deep link users to their relevant settings / system preferences.

await window.deskifier.permissions.request({ arguments })

Arguments

  • permission String (Required)
    Possible values are microphone, camera, screenSharing, and accessiblity. The accessibility value will open the system preferences linked to the accessibility settings, since there's currently no way to request accessibility permissions.

Returns

  • success Boolean
    If access was granted successfully.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Open System Preferences

macOS Windows Opens the device's settings panel, at the specified submenu.

await window.deskifier.permissions.openSystemPreferences({ arguments })

Arguments

  • target String (Required)
    Possible values are camera, microphone, screenSharing, notification and the accessibility value is available on macOS only.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Check For Update

Checks to see if there's an app update available.

await window.deskifier.autoUpdate.check()

Returns

  • success Boolean
    If the update was checked.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • updateAvailable Boolean
    If there is an update available.
  • nextVersion String
    Available update version.

Start App Update

This will force close the app.

Starts the app update.

await window.deskifier.autoUpdate.startUpdate()

Returns

  • success Boolean
    Returns false if the update couldn't be started, or if there is no update available.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Properties

Get Permissions

macOS Windows Returns an object with the current permissions.

Generally, macOS will be the only platform that doesn't have permissions by default. In this case, use the "Request Media Permission" method to gain access to these devices.

You can also deep link users to their relevant settings / system preferences with the "Open System Preferences" method.

await window.deskifier.permissions.getAll()

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • cameraPermissionStatus String
    Can be not-determined, granted, denied, restricted or unknown.
  • microphonePermissionStatus String
    Can be not-determined, granted, denied, restricted or unknown.
  • screenPermissionStatus String
    Can be not-determined, granted, denied, restricted or unknown.
  • accessibilityPermissionStatus String macOS
    Can be not-determined, granted, denied, restricted or unknown. Will return unknown on platforms other than macOS.
  • notificationPermissionStatus String
    Can be not-determined, granted, denied, restricted or unknown.<br>

Return Value Descriptions:

  • not-determined - The user has not yet made a choice regarding whether the application may access the data.
  • restricted - The application is not authorized to access the data. The user cannot change this application’s status, possibly due to active restrictions such as parental controls being in place.
  • denied - The user explicitly denied access to data for the application.
  • authorized - The application is authorized to access the data.
  • provisional - The application is provisionally authorized to access the data. Currently only applicable to the notifications type.
  • unknown - The permission status can not be determined.

Get App Info

Returns metadata about the running app. This call is Synchronous it returns a value directly (no await).

const info = window.deskifier.app.getAppInfo()

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • launchAtStartup Boolean
    If the app is currently set to launch at system startup.
  • launchedWithDeeplink Boolean
    Whether the current instance of the app was launched via a deeplink.
  • deeplinkUrl String
    If the app was launched with a deeplink, this will be populated with the URL used. Empty string otherwise.
  • appName String
    Name of the current app.
  • appVersion String
    The app version.
  • appDist String
    Which distribution the app is currently running as. Can be MAS, DMG, APPX, NSIS, APPIMAGE.
  • willAutoUpdate Boolean
    If the app is set to automatically update when a new version is published.

Events

Note, a deeplink can be used to launch your application. If this happens, this event will fire when the app starts. You can also check via Get App Info.

Deeplinks may also be used when the app is already running, in this case you should show your application.

Fires when the app's deeplink is used.

window.deskifier.deeplink.onUsed((data) => {})

Arguments

  • url String

Example

window.deskifier.deeplink.onUsed((data) => {
   console.log(data.url);
});

//yourAppProtocol://data?foo=bar

Update Available

Fires when a new app version is detected. This also fires after a background download completes (check downloaded to distinguish).

window.deskifier.autoUpdate.onAvailable((data) => {})

Arguments

  • updateAvailable Boolean
    true if an update is available.
  • nextVersion String
    The version string of the available update (if known).
  • downloaded Boolean
    true if the update has finished downloading and is ready to install. When false, the update is still downloading or not yet started.

Example

window.deskifier.autoUpdate.onAvailable((data) => {
    if (data.downloaded) {
        // Prompt the user to restart-to-install
        showBanner(`${data.nextVersion} is ready. Click to install.`);
    } else {
        console.log(`Found update ${data.nextVersion}, downloading...`);
    }
});

Update Progress

Fires repeatedly during an update download, with progress information.

window.deskifier.autoUpdate.onProgress((data) => {})

Arguments

  • percent Number
    Download progress percentage (0–100).
  • transferred Number
    Bytes downloaded so far.
  • total Number
    Total bytes to download.
  • bytesPerSecond Number
    Current download speed.

Update Error

Fires when an update check or download fails.

window.deskifier.autoUpdate.onError((data) => {})

Arguments

  • message String
    Human-readable error description.