1.1. Integration
1.1.1. Using CocoaPods
Add the following content in file Podfile
:
source "https://github.com/TuyaInc/TYPublicSpecs.git"
source 'https://cdn.cocoapods.org/'
platform :ios, '9.0'
target 'your_target_name' do
pod "TuyaSmartPanelSDK"
# If you need the sweeper, please rely on the relevant plug-in of the sweeper
pod "TuyaRNApi/Sweeper"
end
Execute command pod update
in the project's root directory to begin integration.
For the instructions of CocoaPods, please refer to: CocoaPods Guides
1.1.2. Initializing SDK
- Open project setting,
Target => General
, editBundle Identifier
to the value from Tuya develop center. - Import security image to the project and rename as
t_s.bmp
from Preparation Work, then add it intoProject Setting => Target => Build Phases => Copy Bundle Resources
. - Add the following to the project file
PrefixHeader.pch
:
#import <TuyaSmartBaseKit/TuyaSmartBaseKit.h>
#import <TuyaSmartPanelSDK/TuyaSmartPanelSDK.h>
Swift project add the following to the xxx_Bridging-Header.h
file:
#import <TuyaSmartBaseKit/TuyaSmartBaseKit.h>
#import <TuyaSmartPanelSDK/TuyaSmartPanelSDK.h>
- Open file
AppDelegate.m
,and use theApp Key
andApp Secret
obtained from the development platform in the[AppDelegate application:didFinishLaunchingWithOptions:]
method to initialize SDK:
Declaration
Init SDK
- (void)startWithAppKey:(NSString *)appKey secretKey:(NSString *)secretKey;
Parameters
Parameter | Description |
---|---|
appKey | App key |
secretKey | App secret key |
Example
Objc:
[[TuyaSmartSDK sharedInstance] startWithAppKey:<#your_app_key#> secretKey:<#your_secret_key#>];
Swift:
TuyaSmartSDK.sharedInstance()?.start(withAppKey: <#your_app_key#>, secretKey: <#your_secret_key#>)
Now all the prepare work has been completed. You can use the sdk to develop your application now.