Last Updated on : 2023-05-22 06:38:30download
The IPC SDK for iOS helps you implement IP camera (IPC) functionalities on top of the modules provided by the Smart Life App SDK, such as user management, device pairing, home management, and device management.
The SDK supports iOS 9.0 and later. IPCs do not support cloud development solutions. You must integrate the IPC SDK with the Smart Life App SDK during the app development.
Module | Description |
---|---|
TuyaSmartActivatorKit | Device pairing SDK |
TuyaSmartCameraKit | Extension SDK for Tuya-powered IPCs |
TuyaSmartCameraKit
is not a separate library. It depends on certain basic libraries. For more information, see SDK Architecture.
Add the following code block to the Podfile
:
platform :ios, '9.0'
target 'your_target_name' do
pod "TuyaSmartActivatorKit"
pod "TuyaSmartCameraKit"
# pod "TuyaSmartCameraT"
end
To support peer-to-peer (P2P) 1.0 devices, you must add pod "TuyaSmartCameraT"
, and run the command pod update
in the project root directory.
For more information about CocoaPods, see CocoaPods Guides.
// need to add below authorization in info.plist
Privacy - Microphone Usage Description
Privacy - Photo Library Additions Usage Description
Open the project settings, choose Target > General, and then set Bundle Identifier
to the bundle ID for iOS that is specified on the Tuya IoT Platform.
Import the security image downloaded in Preparation to the root directory of the project, rename it as t_s.bmp
. Go to Project Settings > Target > Build Phases, and add this image to Copy Bundle Resources.
Add the following content to the PrefixHeader.pch
file of the project. For a Swift project, the following content can be added to the bridging header file xxx_Bridging-Header.h
.
#import <TuyaSmartBaseKit/TuyaSmartBaseKit.h>
#import <TuyaSmartActivatorKit/TuyaSmartActivatorKit.h>
#import <TuyaSmartCameraKit/TuyaSmartCameraKit.h>
Open the AppDelegate.m
file and initialize the SDK by calling the method [AppDelegate application:didFinishLaunchingWithOptions:]
. The values of AppKey
and AppSecret
generated on the Tuya IoT Platform are used for the initialization.
Objective-C:
[[TuyaSmartSDK sharedInstance] startWithAppKey:<#your_app_key#> secretKey:<#your_secret_key#>];
Swift:
TuyaSmartSDK.sharedInstance()?.start(withAppKey: <#your_app_key#>, secretKey: <#your_secret_key#>)
Now, the SDK is activated and you are ready for app development.
After the video is streamed, the app goes to the background, stays for a while, and then comes back to the foreground. This might cause the app to crash. Error message: Terminated due to signal 13
.
To prevent this crash, add the following code block to the project:
Objective-C:
main.m
int main(int argc, char * argv[]) {
@autoreleasepool {
struct sigaction sa;
sa.sa_handler = SIG_IGN;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
perror("cannot ignore SIGPIPE");
return -1;
}
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
Swift:
AppDelegate.swift
let handler: @convention(c) (Int32) -> () = { sig in
// handle the signal somehow
print("error", sig)
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
signal(SIGPIPE, handler)
return true
}
During the development, you can enable the debug mode and print logs for troubleshooting.
Objective-C:
#ifdef DEBUG
[[TuyaSmartSDK sharedInstance] setDebugMode:YES];
#else
#endif
Swift:
#if DEBUG
TuyaSmartSDK.sharedInstance()?.debugMode = true
#else
#endif
We recommend that you could use the real device for debugging during the development. Using the simulator will cause some functions to be unavailable.
You can view the demo app in the IPC SDK sample repository. Follow the instructions in the Smart Life App SDK demo app, and configure the values of BundleId
, AppKey
, AppSecret
, and security image.
Based on the features of the Smart Life App SDK demo app, the IPC SDK demo app is added with the control panel module for IPCs to implement the following pages:
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback