Life-cycle API
chevron down
 

Life-cycle API

Interface: Companion

The Companion interface provides information about the running companion application, access to permissions, environment information and oAuth access tokens.

Properties

readonly launchReasons

LaunchReasons

Reasons why the application is currently running.

onunload

((this: Companion, event: Event) => any) or undefined

Adds an event listener for when the app is going to be unloaded which can happen any time.

The app will unload after all event listeners have been executed.

NOTE: Blocking the execution for too long will result in sudden termination of the application. Behavior of asynchronous API calls from the listener is undefined.

Methods

yield()

Returns: void

Applications can indicate that they would like to be unloaded. This gives other apps the chance to run instead.

However, the runtime might decide to keep the application running.

Interface: LaunchReasons

Contains the reasons why the application was launched. Multiple reasons, at least one might be set.

Properties

readonly fileTransfer

boolean or undefined

New in SDK 3.0

Set to true if the companion was woken up because of an incoming file transfer.

readonly locationChanged

{ position: Position; } or undefined

Set and contains the latest Position update received from the GPS module.

readonly peerAppLaunched

boolean or undefined

Set to true if the peer app was launched on the device.

readonly settingsChanged

boolean or undefined

Set to true if the companion was woken up because of changes to the settingsStorage.

readonly wokenUp

boolean or undefined

Set to true if the companion was woken up by a periodic timer