# react-native-kiosk-view

> PACKAGE DISCRIPTION HERE

Latest version **0.1.0** (published 2023-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-kiosk-view
pnpm add react-native-kiosk-view
yarn add react-native-kiosk-view
bun add react-native-kiosk-view
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2023-11-23 |
| First published | 2023-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18.0.0 |
| Dependencies | 0 |
| Unpacked size | 21 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jay Vaghela |
| Maintainers | thejayvaghela |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-kiosk-view
- Repository: https://github.com/thejayvaghela/react-native-kiosk-view
- Homepage: https://github.com/thejayvaghela/react-native-kiosk-view#readme
- Issues: https://github.com/thejayvaghela/react-native-kiosk-view/issues
- npm.io page: https://npm.io/package/react-native-kiosk-view

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2023-11-23

## README

# react-native-kiosk-view

A simple kiosk mode for Android in react native.

Does not work with Expo because of its native dependencies.

## Installation

```sh
npm install react-native-kiosk-view
```

## Android Changes

In `MainActivity.java` add the following code:

```java
//...
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.kioskview.Immersive;

public class MainActivity extends ReactActivity {
  //...
  @Override
  public void onBackPressed() {
		if( !Immersive.getActive() ) super.onBackPressed();
		else Immersive.fullscreen(getWindow(), MainActivity.this);
  }

  @Override
  protected void onPause() {
		super.onPause();
		if(Immersive.getActive()) Immersive.moveToFront(getTaskId(),(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
  }

  @Override
  protected void onResume() {
		super.onResume();
		if(Immersive.getActive()) Immersive.fullscreen(getWindow(), MainActivity.this);
  }

  @Override
  protected void onUserLeaveHint() {
		super.onUserLeaveHint();
		if(Immersive.getActive()) {
			Immersive.moveToFront(getTaskId(), (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
			Immersive.fullscreen(getWindow(), MainActivity.this);
		}
  }
}
```

Add below permissions in `AndroidManifest.xml:`

```xml
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
```

The `<intent-filter>` should be atleast:

```xml
<intent-filter>
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.HOME" />
  <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
```

## Usage

```ts
import * as React from 'react';
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
import Kiosk from 'react-native-kiosk-view';

export default function App() {
  const handleFullScreen = () => Kiosk.fullscreen();

  const handleExitFullScreen = () => Kiosk.exitFullscreen();

  return (
    <View style={styles.container}>
      <TouchableOpacity onPress={handleFullScreen}>
        <Text>Enter Kiosk Mode{'\n'}</Text>
      </TouchableOpacity>

      <TouchableOpacity onPress={handleExitFullScreen}>
        <Text>Exit Kiosk Mode</Text>
      </TouchableOpacity>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---
_Source: https://npm.io/package/react-native-kiosk-view · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
