Last Updated on : 2024-06-26 09:57:43download
This topic describes how to use CocoaPods to quickly integrate Tuya Smart Community App SDK for iOS into your project. The SDK requires iOS 10.0 or later.
For more information about CocoaPods, see CocoaPods Guides. We recommend that you update CocoaPods to the latest version.
Add the following code block to the Podfile
:
platform :ios, '10.0'
target 'Your_Project_Name' do
pod 'TuyaCommunityKit'
end
In the root directory of your project, run pod update
.
Open the project settings, click Target > General, and then modify Bundle Identifier
to the iOS Bundle ID set on the Tuya Developer Platform
Import the security image to the root directory of the project, and rename it as t_s.bmp
. Go to Project Settings > Target > Build Phases, and add this image to Copy Bundle Resources.
Add the following code line to the PrefixHeader.pch
file.
#import <TuyaCommunityKit/TuyaCommunityKit.h>
Open the AppDelegate.m
file and initialize the SDK by using the TuyaSmartSDK
class in the method [AppDelegate application:didFinishLaunchingWithOptions:]
.
Use TuyaSmartSDK
to initialize the SDK.
- (void)startWithAppKey:(NSString *)appKey secretKey:(NSString *)secretKey;
Parameters
Parameter | Description |
---|---|
appKey | AppKey |
secretKey | AppSecret |
Example
[[TuyaSmartSDK sharedInstance] startWithAppKey:<#your_app_key#> secretKey:<#your_secret_key#>];
Now, you are ready for app development.
During the development, you can enable the debug mode and print logs for troubleshooting.
#ifdef DEBUG
[[TuyaSmartSDK sharedInstance] setDebugMode:YES];
#else
#endif
In the following example, a demo app is used to describe the process of app development with the App SDK. Before the development of your app, we recommend that you run the demo app.
In the Preparation topic, get the AppKey
, AppSecret
, and security image for iOS. Make sure that the BundleId
, AppKey
, AppSecret
, and security image, are consistent with those used on the Tuya Developer Platform. Any mismatch will cause the SDK development or demo app to be failed.
The demo app supports the following features:
Troubleshoot the error message: Permission Verification Failed
{
"success" : false,
"errorCode" : "SING_VALIDATE_FALED",
"status" : "error",
"errorMsg" : "Permission Verification Failed",
"t" : 1583208740059
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback