1.0.3 • Published 2 years ago

rtn-keepawake v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Keep Awake

This React Native package allows you to prevent the screen from going to sleep while your app is active. It's useful for things like navigation or video playback, where the user expects the app to remain visible over long periods without touch interaction.

Based on New RN Arch (Also Supports Old Arch)

Installation

Using yarn

yarn add rtn-keepawake

For Ios cd ios && pod install && cd ..

Usage

example: hooks

import { useKeepAwake } from 'rtn-keepawake';
import React from 'react';
import { Text, View } from 'react-native';
export default function KeepAwakeExample {
  useKeepAwake();
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>This screen will never sleep!</Text>
    </View>
  );
}

example: components

import KeepAwake from 'rtn-keepawake';
import React from 'react';
import { Text, View } from 'react-native';
export default function KeepAwakeExample {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <KeepAwake />
      <Text>This screen will never sleep!</Text>
    </View>
  );
}

example: functions

import { activateKeepAwake, deactivateKeepAwake } from "rtn-keepawake";
import React from "react";
import { Button, View } from "react-native";
export default class KeepAwakeExample extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
        <Button onPress={this._activate}>Activate</Button>
        <Button onPress={this._deactivate}>Deactivate</Button>
      </View>
    );
  }
  _activate = () => {
    activateKeepAwake();
  };
  _deactivate = () => {
    deactivateKeepAwake();
  };
}
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago