npm.io
0.0.6 • Published 5 years ago

rn-system-brightness

Licence
MIT
Version
0.0.6
Deps
0
Size
89 kB
Vulns
0
Weekly
0
Stars
3

RN System Brightness

Access and update the system brightness on a device Android vs IOS

Install

npm version npm download

yarn add rn-system-brightness
npm i --save rn-system-brightness

Setup

Android

Also update you manifest params and include xmlns:tools

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.baseproject"
  xmlns:tools="http://schemas.android.com/tools"> // <---add

Open the manifest file of your Android project and add

<uses-permission
  android:name="android.permission.WRITE_SETTINGS"
  tools:ignore="ProtectedPermissions"
/>
IOS
cd ios
pod install
API
import Brightness from "rn-system-brightness";

// SET
await Brightness.setBrightness(0.8); // between 0 and 1

// GET
const brightness = await Brightness.getBrightness();

// GET max brightness
const maxBrightness = await Brightness.getMaxBrightness();

// GET Permission ANDROID
const per = await Brightness.hasPermission(); // boolean true or false

// REQUEST ANDROID > 6
await Brightness.requestPermission();

Keywords