> 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/screen/close.md).

# Close screen

***

### 1. Close the screen (`closeView`)

This function closes the current screen. You can use it when ending the service by pressing the "Close" button.

**Signature**

```typescript
function closeView(): Promise<void>;
```

**Example**

```tsx
import { Button } from 'react-native';
import { closeView } from '@granite-js/react-native';

function CloseButton() {
  return <Button title="Close" onPress={closeView} />;
}
```

***

### 2. Set up iOS swipe-back (`setIosSwipeGestureEnabled`)

Enables or disables the gesture to go back by swiping the screen on iOS.

**Signature**

```typescript
function setIosSwipeGestureEnabled(options: { isEnabled: boolean }): Promise<void>;
```

**Parameters**

* **options.isEnabled** · Required · `boolean`

  `true`If true, you can go back by swiping, `false`and if false, swipe-back is disabled.

**Example**

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

function Page() {
  return (
    <>
      <Button title="Turn swipe off" onPress={() => setIosSwipeGestureEnabled({ isEnabled: false })} />
      <Button title="Turn swipe on" onPress={() => setIosSwipeGestureEnabled({ isEnabled: true })} />
    </>
  );
}
```

***

### 3. Control back events (`useBackEvent`)

A Hook that lets you register and remove back events. You can handle back events only while a specific component is active.

**Signature**

```typescript
function useBackEvent(): BackEventControls;
```

**Return value**

* BackEventControls

  An object that controls back events. `addEventListener`to register the event, and `removeEventListener`to remove it.

{% hint style="info" %}
**Please note**

This Hook must be used inside `BackEventProvider` Otherwise, an error will occur.
{% endhint %}

**Example**

```tsx
import { useEffect, useState } from 'react';
import { Alert, Button, View } from 'react-native';
import { useBackEvent } from '@granite-js/react-native';

function UseBackEventExample() {
  const backEvent = useBackEvent();
  const [handler, setHandler] = useState<{ callback: () => void } | undefined>(undefined);

  useEffect(() => {
    const callback = handler?.callback;
    if (callback != null) {
      backEvent.addEventListener(callback);
      return () => {
        backEvent.removeEventListener(callback);
      };
    }
  }, [backEvent, handler]);

  return (
    <View>
      <Button title="Register back event" onPress={() => setHandler({ callback: () => Alert.alert('back') })} />
      <Button title="Remove back event" onPress={() => setHandler(undefined)} />
    </View>
  );
}
```


---

# 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/screen/close.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.
