---
sidebar_position: 0
---

# sos

The `sos` API groups together all functionality the \@signageos/front-applet offers. This is a basic object that provides you with access to
all the applet functionality, such as device information, display control, video playback, and more.

:::warning
All calls to the sos object need to happen after `sos.onReady()` is resolved. After the sOS object is ready, there are global properties available, which can be used for applet customization and device identification.
:::

```ts
// Simple example of using the sos API to play a video.
import sos from '@signageos/front-applet';

sos.onReady().then(async function () {
  startYourApplet(); // Example method to run
  // Any other code
}
```

## Properties

### appletVersion

The `appletVersion` is the version of the current applet.

```ts expandable
readonly appletVersion: string;
```

### authHash

<Admonition type="info" icon="" title="">
  Learn more about using this API [here](https://developers.signageos.io/docs/sos-guides/device-identification)
</Admonition>

The `authHash` property is an alternative device identifier, which is designed for secure pairing and locating devices through
the REST API.

1. The `authHash` is commonly used as a link between the Applet deployed on the device and the device in device management.
2. The `authHash` is unique and can be revoked upon request.
3. The `authHash` can be used as a universal identifier for your Applet application.

```ts expandable
readonly authHash: string;
```

### config

The `config` property is a Key-value dictionary of the applet configuration. It is assigned on the device with timing via Box or SDK/Rest API.

```ts expandable
readonly config: Record<string, number | string | boolean>;
```

## Methods

### onReady()

The `onReady()` method accepts an optional listener which is called after the sos API are loaded and ready. It also returns a promise
which is resolved at the same time as the listener.

```ts expandable
onReady(listener?: () => void): Promise<void>;
```

#### Params

| Name       | Type         | Required        | Description                                                  |
|------------|--------------|-----------------|--------------------------------------------------------------|
| `listener` | `() => void` |  <div>No</div>  | Optional listener which is called when the sos API is ready. |

#### Return value

Promise which is resolved when the sos API is ready.

#### Example

```ts
sos.onReady().then(async function () {
  console.log(await sos.app.getType());
});

sos.onReady(async function () {
  console.log(await sos.app.getType());
});
```

<Separator />

### refresh()

The `refresh()` method initializes the refresh of the applet. Similar to window.location.reload(), but the applet is not downloaded again.

```ts expandable
refresh(): Promise<void>;
```

#### Return value

Promise that is resolved when the refresh is completed.

#### Example

```ts
await sos.refresh();
```

<Separator />

### restore()

The `restore()` method clears all previously played videos, streams, clear display view. The typical case of usage for digital signage
is playing a loop with some specified duration. This method should be called always when the loop is changed. It will clear all
previously played videos, streams, clear display views, and notify for garbage collection.

It stops all video playback and clears out the memory. The following function should be triggered only in a case the whole playback
needs to be restarted as it's completely switching the playback 'loop/playlist'.

```ts expandable
restore(): void;
```

#### Example

```ts
sos.onReady(async function () {
  // Some function which is called when the applet is ready
  sos.restore();
});
```