1.1. Integrate SDK
1.1.1. Use CocoaPods for Quick Integration
SDK Basically Supports System Version 9.0
Add the following content in the Podfile
file.
platform :ios, '9.0'
target 'Your_Project_Name' do
pod "TuyaSmartHomeKit"
end
Then run the pod update
command in the root directory of project.
For use of CocoaPods, please refer to the CocoaPods Guides. It is recommended to update the CocoaPods to the latest version.
1.1.2. Integrate 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
, then add it intoProject Setting => Target => Build Phases => Copy Bundle Resources
.Add the following to the project file
PrefixHeader.pch
:
#import <TuyaSmartHomeKit/TuyaSmartKit.h>
Swift project add the following to the xxx_Bridging-Header.h
file:
#import <TuyaSmartHomeKit/TuyaSmartKit.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.
1.1.3. Debug Mode
During the development we can open debug mode, print the log to analyze some problem.
Objc:
#ifdef DEBUG
[[TuyaSmartSDK sharedInstance] setDebugMode:YES];
#else
#endif
Swift:
#if DEBUG
TuyaSmartSDK.sharedInstance()?.debugMode = true
#else
#endif