> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/common/network-environment/environment.md).

# Runtime Environment

### 1. Checking the running platform (`getPlatformOS`)

`getPlatformOS`is a function that checks the currently running platform. `react-native`of [`Platform.OS`](https://reactnative.dev/docs/0.72/platform#os) It operates based on the value, `ios` or `android` and returns one of the strings.

**Signature**

```typescript
function getPlatformOS(): 'ios' | 'android';
```

**Return value**

* 'ios' | 'android'

  the currently running platform

**Example**

```tsx
import { getPlatformOS } from '@apps-in-toss/framework';
import { Text } from 'react-native';

function Page() {
  const platform = getPlatformOS();

  return <Text>Current platform: {platform}</Text>;
}
```

***

### 2. Checking the application environment (`getOperationalEnvironment`)

`getOperationalEnvironment` Use the function to check which deployment environment the app is currently running in (e.g.: `sandbox`, `Toss`) you can check whether it is running there. If it's running in the Toss app, `'toss'`, and if it's running in a sandbox environment, `'sandbox'`is returned.

The operational environment refers to the context in which the app runs, and it can be used to determine whether specific features are available.

**Signature**

```typescript
function getOperationalEnvironment(): 'toss' | 'sandbox';
```

**Return value**

It is a string representing the current operational environment.

* 'toss' | 'sandbox'

  `'toss'`: Running in the Toss app. `'sandbox'`: Running in the sandbox environment.

**Example**

{% tabs %}
{% tab title="js" %}

```js
import { getOperationalEnvironment } from '@apps-in-toss/web-framework';

const environment = getOperationalEnvironment();
```

{% endtab %}

{% tab title="React" %}

```tsx
import { getOperationalEnvironment } from '@apps-in-toss/web-framework';
import { Text } from '@toss/tds-mobile';

function EnvironmentInfo() {
  const environment = getOperationalEnvironment();

  return <Text>{`The current execution environment is '${environment}'.`}</Text>;
}
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { getOperationalEnvironment } from '@apps-in-toss/framework';
import { Text } from '@toss/tds-react-native';

function EnvironmentInfo() {
  const environment = getOperationalEnvironment();

  return <Text>{`The current execution environment is '${environment}'.`}</Text>;
}
```

{% endtab %}
{% endtabs %}

Some features may need to be provided only in specific deployment environments. Below is `sandbox` an example of providing special features only in a given environment.

```tsx{4,8-9}
import { View, Text } from 'react-native';
import { getOperationalEnvironment } from '@apps-in-toss/framework';

const isSandbox = getOperationalEnvironment() === 'sandbox'; // variable that checks whether the environment is 'sandbox'

function Component() {
  const handlePress = () => {
    if (isSandbox) {
      // feature to provide in the 'sandbox' environment
    } else {
      // feature to provide in other environments
    }
  };

  return <Button onPress={handlePress}>View details</Button>;
}
```

***

### 3. Checking the device's unique identifier (`getDeviceId`)

`getDeviceId` The function returns the unique identifier of the device being used as a string. It can be used to save settings or data per device, or to identify the user's device for logging and analysis. It's also useful for distinguishing multiple devices used by the same user.

**Signature**

```typescript
function getDeviceId(): string;
```

**Return value**

* string

  It is a string representing the device's unique identifier.

**Example**

{% tabs %}
{% tab title="js" %}

```js
import { getDeviceId } from '@apps-in-toss/web-framework';

const deviceId = getDeviceId();
```

{% endtab %}

{% tab title="React" %}

```tsx
import { getDeviceId } from '@apps-in-toss/web-framework';
import { useState } from 'react';

const DeviceInfo = () => {
  const [deviceId, setDeviceId] = useState<string | null>(null);

  const fetchDeviceId = async () => {
    setDeviceId(getDeviceId());
  };

  return (
    <div>
      <button onClick={fetchDeviceId}>Get device ID</button>
      {deviceId && <p>Device ID: {deviceId}</p>}

  );
};
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { getDeviceId } from '@apps-in-toss/framework';
import { Text } from '@toss/tds-react-native';

function MyPage() {
  const id = getDeviceId();

  return <Text>User's device unique identifier: {id}</Text>;
}
```

{% endtab %}
{% endtabs %}

***

### 4. Getting the scheme value (`getSchemeUri`)

`getSchemeUri`returns the scheme value used when the screen was first entered. URI changes caused by page navigation are not reflected.

**Signature**

```typescript
function getSchemeUri(): string;
```

**Return value**

* string

  It returns the scheme value used when the screen was first entered.

**Example**

```tsx
import { getSchemeUri } from '@apps-in-toss/framework';
import { Text } from 'react-native';

function MyPage() {
  const schemeUri = getSchemeUri();

  return <Text>Scheme value used when first entering the screen: {schemeUri}</Text>;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/common/network-environment/environment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
