$ npm install react-native-open-security-settings --save
$ react-native link react-native-open-security-settings
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.reactlibrary.OpenSecuritySettingsPackage;
to the imports at the top of the file - Add
new OpenSecuritySettingsPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-open-security-settings' project(':react-native-open-security-settings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-open-security-settings/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-open-security-settings')
import {Platform} from 'react-native'
import OpenSecuritySettings from 'react-native-open-security-settings';
if(Platform.OS == 'android'){
OpenSecuritySettings.openSecuritySettings()
}else{
Linking.openURL('app-settings:')
}
//Additional Method: isDeviceSecure
let isSecure = await OpenSecuritySettings.isDeviceSecure();