React native unlock screen and wakeup device for Android
$ npm install react-native-react-native-unlock-device --save
$ react-native link react-native-react-native-unlock-device
android/app/src/main/java/[...]/MainActivity.java
import com.reactlibrary.RNUnlockDevicePackage;
to the imports at the top of the filenew RNUnlockDevicePackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-react-native-unlock-device'
project(':react-native-react-native-unlock-device').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-react-native-unlock-device/android')
android/app/build.gradle
:
compile project(':react-native-react-native-unlock-device')
Add this this AndroidManifest.xml
<uses-permission android:name="android.permission.WAKE_LOCK" ></uses-permission>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
import RNUnlockDevice from 'react-native-unlock-device';
// TODO: What to do with the module?
RNUnlockDevice.unlock()
.then(() => console.log('Success'))
.catch(error => console.log('Error', error));