0.0.6 • Published 3 years ago

rn-system-brightness v0.0.6

Weekly downloads
20
License
MIT
Repository
github
Last release
3 years ago

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();