Last Updated on : 2022-03-03 06:52:12download
Device Control UI BizBundle is the core container of the control panel for each Powered by Tuya (PBT) device. Based on Tuya Smart Residence App SDK for iOS, the UI BizBundle encapsulates the APIs to load and control panels and accelerates the application development process.
The following features are supported:
Add the components of the Device Control UI BizBundle to the Podfile
and run the command pod update
.
source "https://github.com/TuyaInc/TuyaPublicSpecs.git"
source 'https://cdn.cocoapods.org/'
target 'your_target_name' do
# TuyaSmartResidence SDK
pod "TuyaSmartResidenceKit"
# Adds the UI BizBundle.
pod 'TuyaSmartResidencePanelBizBundle'
# Depends on the robot vacuum plug-ins to integrate with their features if needed.
# pod 'TuyaRNApi/Sweeper'
end
The UI BizBundle includes the open source React Native framework (v0.59.10).
If your iOS project does not integrate with React Native, follow the procedure in this topic to integrate with the UI BizBundle.
If your iOS project has integrated with React Native, perform the following steps to check whether the UI BizBundle can be integrated:
If both methods failed, the UI BizBundle cannot be integrated.
The BizBundle encapsulates a series of React Native API methods for panels. This requires specific declarations of privacy and permissions from Apple.
If a device panel supports album features such as the cloud album, add the following permission declaration to info.plist
of your project:
NSPhotoLibraryAddUsageDescription
If a device panel supports camera features such as the cloud album, add the following permission declaration to info.plist
of your project:
NSCameraUsageDescription
If a device panel supports location features, add the following permission declaration to info.plist
of your project:
NSLocationWhenInUseUsageDescription
If a device panel supports microphone features such as the music light panel, add the following permission declaration to info.plist
of your project:
NSMicrophoneUsageDescription
If a device panel supports Bluetooth features, add the following permission declaration to info.plist
of your project:
NSBluetoothAlwaysUsageDescription
NSBluetoothPeripheralUsageDescription
The UI BizBundle relies on the implementation of the protocol TuyaSmartResidencePanelProtocol
to provide services. You can view the TuyaSmartResidencePanelProtocol.h
file in the TYModuleServices
component.
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TuyaSmartResidencePanelProtocol.h>
// Clears cached data of the panel.
- (void)cleanPanelCache;
/**
* Returns the device panel controller.
*
* @param deviceModel The device model.
* @param initialProps The custom initialization parameter to be set in `initialProps` of the RN application with the key 'extraInfo'.
* @param contextProps The context of the custom panel to be set in `Panel Context` with the key 'extraInfo'.
* @param completionHandler The callback of the view controller.
*/
- (void)getPanelViewControllerWithDeviceModel:(TuyaSmartDeviceModel *)deviceModel
initialProps:(nullable NSDictionary *)initialProps
contextProps:(nullable NSDictionary *)contextProps
completionHandler:(void (^ _Nullable)(__kindof UIViewController * _Nullable panelViewController, NSError * _Nullable error))completionHandler;
/**
* Returns the group panel controller.
*
* @param groupModel The group model.
* @param initialProps The custom initialization parameter to be set in `initialProps` of the RN application with the key 'extraInfo'.
* @param contextProps The context of the custom panel to be set in `Panel Context` with the key 'extraInfo'.
* @param completionHandler The callback of the view controller.
*/
- (void)getPanelViewControllerWithGroupModel:(TuyaSmartGroupModel *)groupModel
initialProps:(nullable NSDictionary *)initialProps
contextProps:(nullable NSDictionary *)contextProps
completionHandler:(void (^ _Nullable)(__kindof UIViewController * _Nullable panelViewController, NSError * _Nullable error))completionHandler;
// The RN version number.
- (NSString *_Nonnull)rnVersionForApp;
This UI BizBundle is used to load devices and implement features of different devices. For this purpose, implement the following dependent protocols:
TuyaSmartResidenceDeviceDetailProtocol
: implements the activity of tapping and navigation in the top-right corner of the device panel.
/**
Tap the button in the top-right corner of the device panel to navigate to the device details page.
@param device The device.
@param group The group if any. It is optional.
*/
- (void)gotoDeviceDetailDetailViewControllerWithDevice:(TuyaSmartDeviceModel *)device group:(TuyaSmartGroupModel *)group;
TuyaSmartResidenceGroupHandleProtocol
: implements the activity of navigation to a mesh group page on the panel for a Bluetooth mesh device. The following API method is implemented:
/**
Navigates to a local mesh group.
@param query The initial data.
@param Specifies whether to present by using the `navigator` method.
@param success
@param failure
*/
- (void)presentMeshLocalGroupWithQueryData:(NSDictionary *)query
isNav:(BOOL)isNav;
Before the UI BizBundle is called, the following method must be implemented for the site:
[self.site fetchSiteDetailWithSuccess:^(TuyaResidenceSiteModel * _Nonnull siteModel) {
} failure:^(NSError *error) {
}];
Then, implement the protocol method currentFamilyId
in TYFamilyProtocol
.
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYFamilyProtocol.h>
- (void)initCurrentSite {
// Registers the protocol to be implemented.
[[TuyaSmartBizCore sharedInstance] registerService:@protocol(TYFamilyProtocol) withInstance:self];
}
// Implements the target protocol method.
- (long long)currentFamilyId {
return @"site id";
}
id<TuyaSmartResidencePanelProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TuyaSmartResidencePanelProtocol)];
[impl cleanPanelCache];
id<TuyaSmartResidencePanelProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TuyaSmartResidencePanelProtocol)];
// Returns the panel view controller and enables automatic navigation.
if (deviceModel) {
[impl getPanelViewControllerWithDeviceModel:deviceModel initialProps:nil contextProps:nil completionHandler:^(__kindof UIViewController * _Nullable panelViewController, NSError * _Nullable error) {
[self.navigationController pushViewController:panelViewController animated:YES];
}];
} else if (groupModel) {
[impl getPanelViewControllerWithGroupModel:groupModel initialProps:nil contextProps:nil completionHandler:^(__kindof UIViewController * _Nullable panelViewController, NSError * _Nullable error) {
[self.navigationController pushViewController:panelViewController animated:YES];
}];
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback