Skip to content

riteshshukla04/kiosk-mode-react-native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

03ff468 · Jun 4, 2024

History

11 Commits
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 4, 2024
Jun 1, 2024
Jun 1, 2024
Jun 4, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024
Jun 1, 2024

Repository files navigation

kiosk-mode-react-native

A Library for setting up kiosk mode on Android with react native

Installation

npm install kiosk-react-native

Usage

import { enableKioskMode, disableKioskMode } from 'kiosk-react-native';

// Enable Kiosk Mode
enableKioskMode();

// Disable Kiosk Mode
disableKioskMode();

For Higher Order Access

We need device owner permission for the app for higher order access like disable volume buttons,prevent uninstallation etc.

Add below configuration to AndroidManifest.xml(android/app/src/main/AndroidManifest.xml)

Add android:testOnly . This will allow to developers to uninstall and remove admin for the app.

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:testOnly="true" 
      ...Rest of the App

Now create a new "device_owner.xml" file (android/app/src/main/xml/device_owner.xml) and add the following code.

    <?xml version="1.0" encoding="utf-8"?>
    <device-admin>
        <uses-policies>
            <limit-password/>
            <watch-login/>
            <reset-password/>
            <force-lock/>
            <wipe-data/>
            <expire-password/>
            <encrypted-storage/>
            <disable-camera/>
        </uses-policies>
    </device-admin>

Add a new reciever to your AndroidManifest.xml(android/app/src/main/AndroidManifest.xml).

    <receiver
        android:name="com.kiosk.RNKioskDevice"
        android:label="@string/app_name"
        android:exported="true"
        android:permission="android.permission.BIND_DEVICE_ADMIN">
        <meta-data
            android:name="android.app.device_admin"
            android:resource="@xml/device_owner" />
        <intent-filter>
            <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
        </intent-filter>
    </receiver>

Finally run the following script using adb

adb shell dpm set-device-owner <YourPackageName>/com.kiosk.RNKioskDevice

Rebuild the app. The app should run in admin mode now.

To Remove the device from owner

adb shell dpm remove-active-admin <YourPackageName>/com.kiosk.RNKioskDevice

License

MIT


Made with create-react-native-library

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published