- Notifications
You must be signed in to change notification settings - Fork1
React Native Tuya SDK wrapper library, extended for use with the Brass Monkey Chiller
License
parallax/react-native-tuya
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a fork ofTuyaInc/tuyasmart-home-sdk-react-native, fixing a lot of issues we came across and a better install guide. It also uses TypeScript. We use it currently in multiple projects for clients and it is stable.
Some features are not implemented, feel free to send a PR for those missing features. Unfortunately there is no demo yet
Tuya Smart APP SDK provides the interface package for the communication with hardware and Tuya Cloud to accelerate the application development process, including the following features:
Hardware functions (network configuration, control, status reporting, regular tasks, groups, firmware upgrades, sharing)Account system (phone number, email registration, login, password reset and other general account functions)Tuya Cloud HTTP API interface package
npm install @volst/react-native-tuyaThis library contains native code which is automatically linked in React Native >= 0.59. For iOS, runcd ios && pod install.
In the Tuya development environment create a new app and make sure you have an "App key", "App secret" and "Secure image".Read how to do this.
Put the secure image into the root path of your project asexplained here.
Inios/AppDelegate.m, add the following import;
#import<TuyaSmartHomeKit/TuyaSmartKit.h>
Then, under theroootView.backgroundColor line in the same file, add this:
#ifdef DEBUG [[TuyaSmartSDKsharedInstance]setDebugMode:YES]; #endif [[TuyaSmartSDKsharedInstance]startWithAppKey:@"xxx"secretKey:@"xxx"];
Now replace thexxx with your app key and secret key.
Assuming you already have created an app in the Tuya development environment (otherwise follow the iOS steps before this), followthese steps. You should now have an app key, app secret and security image for Android. Make sure the security image is put inandroid/src/main/assets/t_s.bmp.
Open yourAndroidManifest.xml and put the followingin the<application> tag:
<meta-dataandroid:name="TUYA_SMART_APPKEY"android:value="xxx" /><meta-dataandroid:name="TUYA_SMART_SECRET"android:value="xxx" />
Replace thexxx with your app key and secret key.
Now openMainApplication.java and add the following import to the top:
importcom.tuya.smart.rnsdk.core.TuyaCoreModule;
Change theonCreate function to look like this:
@OverridepublicvoidonCreate() {super.onCreate();SoLoader.init(this,/* native exopackage */false);initializeFlipper(this);// Remove this line if you don't want Flipper enabledTuyaCoreModule.Companion.initTuyaSDKWithoutOptions(this);}
Now you can try to build, but you'll probably run into an error saying that it can't choose betweenlibc++_shared or something. One fix for this (don't know if it's the best fix) is to openandroid/app/build.gradle and add this;
android { ... packagingOptions { pickFirst '**/armeabi-v7a/libc++_shared.so' pickFirst '**/x86/libc++_shared.so' pickFirst '**/arm64-v8a/libc++_shared.so' pickFirst '**/x86_64/libc++_shared.so' pickFirst '**/x86/libjsc.so' pickFirst '**/armeabi-v7a/libjsc.so' }}Now you can actually use the methods in this package. Unfortunately I don't have time to document them all, so it is advised to read the source code, but here's a start.
To login with an existing account:
import{loginWithEmail}from'@volst/react-native-tuya';awaitloginWithEmail({countryCode:'+1',email:'you@example.com',password:'testtest'});
To register a new account you first need to validate the email address. And then actually register using the code in the email.
import{getRegisterEmailValidateCode,registerAccountWithEmail}from'@volst/react-native-tuya';awaitgetRegisterEmailValidateCode({countryCode:'+1',email:'you@example.com'});...awaitregisterAccountWithEmail({countryCode:'+1',email:'you@example.com',password:'testtest',validateCode:'xxxxxx'})
To get the currently logged in user:
import{getCurrentUser}from'@volst/react-native-tuya';constuser=awaitgetCurrentUser();
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
Bundles the package to thedist folder.The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
About
React Native Tuya SDK wrapper library, extended for use with the Brass Monkey Chiller
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Kotlin45.7%
- Objective-C43.2%
- Java6.4%
- TypeScript4.1%
- Other0.6%

