$ npm install react-native-device-locker --save
$ react-native link react-native-device-locker
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-device-locker
and addDeviceLocker.xcodeproj
- In XCode, in the project navigator, select your project. Add
libDeviceLocker.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import org.vosie.reactnative.devicelocker.DeviceLockerPackage;
to the imports at the top of the file - Add
new DeviceLockerPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-device-locker' project(':react-native-device-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-locker/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-device-locker')
- In Visual Studio add the
DeviceLocker.sln
innode_modules/react-native-device-locker/windows/DeviceLocker.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Device.Locker.DeviceLocker;
to the usings at the top of the file - Add
new DeviceLockerPackage()
to theList<IReactPackage>
returned by thePackages
method
import DeviceLocker from 'react-native-device-locker';
// TODO: What to do with the module?
DeviceLocker.requestWakeLock(DeviceLocker.PARTIAL_WAKE_LOCK).then((lockerId) => {
// save lockerId for releasing
});
DeviceLocker.releaseWakeLock(lockerId);
- Since we don't really develop iOS app, we may need help to make the same feature with iOS.
- Basically, we should remove the Windows phone support. The template is generated by a tool.
- Add wifi locker
- Add a function to lock screen programmably, if possible.