Giter VIP home page Giter VIP logo

test-expo-module's Introduction

React Native Tuya

A React Native wrapper for Tuya's Smart Life SDK.

Android Setup

Preparing the aar file

Get the aar file

Get the security-algorithm.zip from tuya IoT platform.

Removing libc++shared.so

  1. Unzip the aar file from the zip file you downloaded
unzip security-algorithm.aar -d tempFolder
  1. Manually remove libc++_shared.so from tempFolder/jni/*/libc++_shared.so
  2. Repack the aar file
zip -r ../security-algorithm-stripped.aar *

Adding the aar file to your project

place the security-algorithm-stripped.aar under android/app/libs/security-algorithm-stripped.aar

Add maven repo

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 dependency

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 key and secret

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.

Configuring keystore

You have to follow steps here to configure to sign with a certificate, and upload the SHA256 of the certificate to tuya IoT.

Initialize the SDK

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
    // ...
  }

iOS Setup

Prepare security image

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

Add pods to your iOS project

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 */

Initialize the SDK

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"];
}

API documentation

Installation in managed Expo projects

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.

Installation in bare React Native projects

For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.

Add the package to your npm dependencies

npm install rn-tuya

Configure for iOS

Run npx pod-install after installing the npm package.

Configure for Android

Contributing

Contributions are very welcome! Please refer to guidelines described in the contributing guide.

test-expo-module's People

Contributors

elabar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.