1.0.7 • Published 5 months ago
rnttlock v1.0.7
��#
suporte@codemaker.pt
Installation
yarn add @codemakerpt/react-native-ttlock
Add configuration to project
iOS
cd ./ios && pod install && cd ../
- In XCode
TARGETS
�'info
�' add keyPrivacy - Bluetooth Peripheral Usage Description
valueyour description for bluetooth
and keyPrivacy - Bluetooth Always Usage Description
valueyour description for bluetooth
Android
- AndroidManifest.xml configuration:
(1) Add 'xmlns:tools="http://schemas.android.com/tools"' to element
(2) Add 'tools:replace="android:label"' to element
(3) Additional permissions:
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
android 12 needs below permission.
<!--
Needed only if your app looks for Bluetooth devices.
You must add an attribute to this permission, or declare the
ACCESS_FINE_LOCATION permission, depending on the results when you
check location usage in your app.
-->
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<!--
Needed only if your app makes the device discoverable to Bluetooth
devices.
-->
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<!--
Needed only if your app communicates with already-paired Bluetooth
devices.
-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
- In order to get the permission request result in ttlock plugin, in MainActivity extends ReactActivity, you need override the onRequestPermissionsResult method and add below code:
(1) java code:
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
ReactInstanceManager mReactInstanceManager = getReactNativeHost().getReactInstanceManager();
TtlockModule ttlockModule = mReactInstanceManager.getCurrentReactContext().getNativeModule(TtlockModule.class);
ttlockModule.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
- When you release the apk, you need disable proguard in release builds.Config buildTypes in build.gradle like this:
repositories {
buildTypes {
release {
minifyEnabled false
shrinkResources false
}
}
}
- Support min sdk version is 18
defaultConfig {
minSdkVersion 18
}
- On Settings.Gradle
include ':react-native-ttlock'
project(':react-native-ttlock').projectDir = new File(rootProject.projectDir, '../node_modules/@codemakerpt/react-native-ttlock/android')
- On Build.Gradle (App)
dependencies {
...REST OF YOUR DEPENDENCIES
implementation project(":react-native-ttlock")
}