react-native-screen-idle-timer
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

react-native-screen-idle-timer

Prevent screen fron going to sleep on both iOS and Android.

Installation

npm install react-native-screen-idle-timer

Usage

import ScreenIdleTimer from 'react-native-screen-idle-timer';

// Method 1
class MyComponent extends Component {
  render() {
    if (this.props.screenShouldBeAwake) {
      return (
        <View>
          <Text>Screen will be kept awake</Text>
          <ScreenIdleTimer />
        </View>
      )
    } else {
      return (
        <View>
          <Text>Screen can sleep</Text>
        </View>
      );
    }
  }
}

// Method 2
function changeKeepAwake(shouldBeAwake) {
  if (shouldBeAwake) {
    ScreenIdleTimer.activate();
  } else {
    ScreenIdleTimer.deactivate();
  }
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-screen-idle-timer

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

52.3 kB

Total Files

20

Last publish

Collaborators

  • akash_maurya