Class: Application

Application

Constructor

new Application(options, callbackopt, errorCallbackopt)

Creates a new Application.

Best practice is to invoke with the new operand. See the application.constructor tutorial for an example. Failure to use the new operand will result in a console warning (but will otherwise succeed).

Parameters:
Name Type Attributes Description
options fin.desktop.Application~options

Application creation options. See options for more details.

callback successCallback <optional>

Callback on success

errorCallback errorCallback <optional>

Callback on error

Tutorials:

Methods

(static) createFromManifest(manifestUrl, callbackopt, errorCallbackopt)

Retrieves application's manifest and returns a wrapped application. Windows

Parameters:
Name Type Attributes Description
manifestUrl string

The URL of app's manifest.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

(static) getCurrent() → {fin.desktop.Application}

Returns an instance of the currently running application.

Tutorials:
Returns:
Type
fin.desktop.Application

(static) wrap(uuid) → {fin.desktop.Application}

Returns an Application object that represents an existing application.

Parameters:
Name Type Description
uuid string

The UUID of the application to be wrapped.

Tutorials:
Returns:
  • fin.desktop.Application Object.
Type
fin.desktop.Application

addEventListener(type, listener, callbackopt, errorCallbackopt)

Registers an event listener on the specified event.

Parameters:
Name Type Attributes Description
type string

The type of the event.

listener function

Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

close(forceopt, callbackopt, errorCallbackopt)

Closes the application and any child windows created by the application.

Parameters:
Name Type Attributes Default Description
force boolean <optional>
false

Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getChildWindows(callbackopt, errorCallbackopt)

Retrieves an array of wrapped fin.desktop.Windows for each of the application’s child windows.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getGroups(callbackopt, errorCallbackopt)

Retrieves an array of active window groups for all of the application's windows. Each group is represented as an array of wrapped fin.desktop.Windows.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getInfo(callbackopt, errorCallbackopt)

Retrieves information about the application.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getManifest(callbackopt, errorCallbackopt)

Retrieves the JSON manifest that was used to create the application. Invokes the error callback if the application was not created from a manifest.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getParentUuid(callbackopt, errorCallbackopt)

Retrieves UUID of the application that launches this application. Invokes the error callback if the application was created from a manifest.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getShortcuts(callbackopt, errorCallbackopt)

Retrieves current application's shortcut configuration. Windows

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getTrayIconInfo(callbackopt, errorCallbackopt)

Retrieves information about the system tray.

The only information currently returned is the position and dimensions.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getWindow() → {fin.desktop.Window}

Returns an instance of the main Window of the application

Tutorials:
Returns:

window - fin.desktop.Window

Type
fin.desktop.Window

isRunning(callbackopt, errorCallbackopt)

Determines if the application is currently running.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

registerUser(userName, appName, callbackopt, errorCallbackopt)

Manually registers a user with the licensing service. The only data sent by this call is userName and appName. Windows

Parameters:
Name Type Attributes Description
userName string

username to be passed to the RVM.

appName string

app name to be passed to the RVM.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

removeEventListener(type, listener, callbackopt, errorCallbackopt)

Removes a previously registered event listener from the specified event.

Parameters:
Name Type Attributes Description
type string

The type of the event.

listener function

Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

removeTrayIcon(callbackopt, errorCallbackopt)

Removes the application’s icon from the tray.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

restart(callbackopt, errorCallbackopt)

Restarts the application.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

run(callbackopt, errorCallbackopt)

Runs the application. When the application is created, run must be called.

Parameters:
Name Type Attributes Description
callback successCallback <optional>

called if the method succeeds. See success callback for shape.

errorCallback errorCallback <optional>

called if there is a network error. See error callback for shape.

Tutorials:

scheduleRestart(callbackopt, errorCallbackopt)

Instructs the RVM to schedule one restart of the application. Windows

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

setShortcuts(config, callbackopt, errorCallbackopt)

Sets new application's shortcut configuration. Windows

Parameters:
Name Type Attributes Description
config Object

New application's shortcut configuration.

Properties
Name Type Attributes Description
desktop Boolean <optional>

Enable/disable desktop shortcut.

startMenu Boolean <optional>

Enable/disable start menu shortcut.

systemStartup Boolean <optional>

Enable/disable system startup shortcut.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

setTrayIcon(iconUrl, listeners, callbackopt, errorCallbackopt)

Adds a customizable icon in the system tray and notifies the application when clicked.

Parameters:
Name Type Attributes Description
iconUrl string

Image URL to be used as the icon.

listeners trayIconClickEventListener | object

Hash of tray icon listeners. If you only need a click listener, you may provide it here as a shortcut.

listeners.clickListener trayIconClickEventListener <optional>
listeners.hoverListener trayIconHoverEventListener <optional>
callback function <optional>

Called if the method succeeds.

errorCallback function <optional>

Called if the method fails. The reason for failure is passed as an argument.

Tutorials:

terminate(callbackopt, errorCallbackopt)

Closes the application by terminating its process.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

wait(callbackopt, errorCallbackopt)

Waits for a hanging application. This method can be called in response to an application "not-responding" to allow the application to continue and to generate another "not-responding" message after a certain period of time.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Type Definitions

options

Application creation options.

This is the options object required by the Application constructor.

Some "options" are actually not options but are required:

  • uuid is required in the app manifest as well as by the fin.desktop.Application constructor
  • name is optional in the app manifest but required by the constructor
  • url is optional in both the app manifest and the constructor but is usually given (defaults to "about:blank" when omitted).

This jsdoc typedef mirrors the ApplicationOptions TypeScript interface in @types/openfin.

IMPORTANT NOTE: This object inherits all the properties of the window creation options object, which will take priority over those of the same name that may be provided in mainWindowOptions.

Type:
  • object
Properties:
Name Type Attributes Default Description
disableIabSecureLogging boolean <optional>
false

When set to true it will disable IAB secure logging for the app.

loadErrorMessage string <optional>
"There was an error loading the application."

An error message to display when the application (launched via manifest) fails to load. A dialog box will be launched with the error message just before the runtime exits. Load fails such as failed DNS resolutions or aborted connections as well as cancellations, e.g., window.stop(), will trigger this dialog. Client response codes such as 404 Not Found are not treated as fails as they are valid server responses.

mainWindowOptions fin.desktop.Window~options <optional>

The options of the main window of the application. For a description of these options, click the link (in the Type column).

name string <optional>

The name of the application (and the application's main window).

If provided, must match uuid.

nonPersistent boolean <optional>
false

A flag to configure the application as non-persistent. Runtime exits when there are no persistent apps running.

plugins boolean <optional>
false

Enable Flash at the application level.

url string <optional>
"about:blank"

The url to the application (specifically the application's main window).

uuid string

The Unique Universal Identifier (UUID) of the application, unique within the set of all other applications running in the OpenFin Runtime.

Note that name and uuid must match.

webSecurity boolean <optional>
true

When set to false it will disable the same-origin policy for the app.