A React Native wrapper for Tuya's Smart Life SDK.
Get the security-algorithm.zip
from tuya IoT platform.
- Unzip the aar file from the zip file you downloaded
unzip security-algorithm.aar -d tempFolder
- Manually remove
libc++_shared.so
fromtempFolder/jni/*/libc++_shared.so
- Repack the aar file
zip -r ../security-algorithm-stripped.aar *
place the security-algorithm-stripped.aar
under android/app/libs/security-algorithm-stripped.aar
Add the following lines in android/build.gradle
allprojects {
repositories {
maven { url 'https://maven-other.tuya.com/repository/maven-releases/' }
maven { url "https://maven-other.tuya.com/repository/maven-commercial-releases/" }
// ...
}
}
add the following lines in android/app/build.gradle
android {
defaultConfig {
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'com.thingclips.smart:thingsmart:5.0.1'
}
Add the following lines in android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.dasher.smarthome" xmlns:tools="http://schemas.android.com/tools">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:allowBackup">
<meta-data android:name="THING_SMART_APPKEY" android:value="key"/>
<meta-data android:name="THING_SMART_SECRET" android:value="secret"/>
</application>
</manifest>
Make sure you added xmlns:tools="http://schemas.android.com/tools"
in manifest
and tools:replace="android:allowBackup"
in application
as well.
You have to follow steps here to configure to sign with a certificate, and upload the SHA256 of the certificate to tuya IoT.
Add the the following lines in android/app/src/main/java/xxx/xxx/xxx/MainApplication.java
import com.thingclips.smart.home.sdk.ThingHomeSdk; // <-- import the SDK
@Override
public void onCreate() {
super.onCreate();
ThingHomeSdk.init(this); // <-- init the SDK
// ...
}
Goto Tuya IoT platform and download the iOS SDK.
Paste the SDK in ios/tuyaSDK
. The content in the directory should look like this
- tuyaSDK
- Build
- ThingSmartCryption.xcframework
- VendorsXCFramework
- ThingSmartCryption.podspec
open your podfile ios/Podfile
, and add the following lines
source 'https://github.com/CocoaPods/Specs'
source 'https://github.com/tuya/TuyaPublicSpecs.git'
source 'https://github.com/tuya/tuya-pod-specs.git'
target 'yourproject' do
// ...
pod "ThingSmartCryption", :path =>'./tuyaSDK'
pod "ThingSmartHomeKit"
We also need to add a header file. Open your iOS project via XCode, right click on the project and add a PrefixHeader.pch
file by selecting pch
file.
#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#import <ThingSmartHomeKit/ThingSmartKit.h>
#endif /* PrefixHeader_pch */
Open AppDelegate.mm
and add this line to init the SDK with your key and secret.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
self.initialProps = @{};
[[ThingSmartSDK sharedInstance] startWithAppKey:@"key" secretKey:@"secret"];
}
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects โ it is likely to be included in an upcoming Expo SDK release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
npm install rn-tuya
Run npx pod-install
after installing the npm package.
Contributions are very welcome! Please refer to guidelines described in the contributing guide.