Migrate to BizBundle SDK

Last Updated on : 2022-06-23 10:10:18download

The new version of the camera device control biz bundle provides a brand-new access method and integrates multiple biz bundle quickly through componentization. For more information, see TuyaSmartCameraPanelBizBundle.

Integrated migration

The Podfile reference is changed to the following form:

source "https://github.com/tuya/TuyaPublicSpecs.git"
source 'https://cdn.cocoapods.org/'

target 'your_target_name' do
  # TuyaSmart SDK
  pod "TuyaSmartHomeKit"
  # Add device control biz bundle, need to specify a fixed version number
  pod 'TuyaSmartPanelBizBundle', 'xxx'
  # add cameraBizBundle
  pod 'TuyaSmartCameraPanelBizBundle', 'xxx'
  # add cameraRNPanelBizBundle
  pod 'TuyaSmartCameraRNPanelBizBundle', 'xxx'
end

Interface migration

The old version of the SDK provides the TuyaSmartCameraPanelSDK class to implement the loading camera device control panel, and the new version of the business package provides a set of component solutions to call the functional interface of each business package.

Note: The new version (TuyaSmartCameraPanelBizBundle) and the old version (TuyaSmartCameraPanelSDK) are incompatible and cannot be integrated at the same time.

Open panel

The old calling method is:

[TuyaSmartPanelSDK sharedInstance].homeId = deviceModel.homeId;
[[TuyaSmartPanelSDK sharedInstance] gotoPanelViewControllerWithDevice:deviceModel completion:^(NSError *error) {
     NSLog(@"load error: %@", error);
}];

Switch to the new calling method:

Please check the TuyaSmartPanelBizBundle User Guide

id<TYPanelProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYPanelProtocol)];
[impl gotoPanelViewControllerWithDevice:deviceModel group:nil initialProps:nil contextProps:nil completion:^(NSError * _Nullable error) {
    if (error) {
        NSLog(@"Load error: %@", error);
    }
}];

Panel delegate

The old version provides TuyaSmartPanelSDKDelegate callback events in the panel, and the new version provides multiple Protocol callback events of different types.

The Callback for Can Not Find Panel Container

The old calling method is:

#pragma mark - TuyaSmartPanelSDKDelegate

- (nullable UIViewController *)requireSpecialPanelForDevice:(nullable TuyaSmartDeviceModel *)device orGroup:(nullable TuyaSmartGroupModel *)group {

}

Switch to the new calling method:

Different protocols are provided for different types of devices, for example:

  • TYRNCameraProtocol: IPC ReactNative Panel. You can choose to implement it yourself, or directly access the IPC ReactNative Bizbundle TuyaSmartCameraRNPanelBizBundle.

    [[TuyaSmartBizCore sharedInstance] registerService:@protocol(TYRNCameraProtocol) withInstance:self];
    
    #pragma mark - TYRNCameraProtocol
    - (UIViewController *)cameraRNPanelViewControllerWithDeviceId:(NSString *)devId {
        
    }
    
  • TYCameraProtocol: IPC Native Panel. You can choose to implement it yourself, or directly access the IPC Native Bizbundle TuyaSmartCameraPanelBizBundle.

    [[TuyaSmartBizCore sharedInstance] registerService:@protocol(TYCameraProtocol) withInstance:self];
    
    #pragma mark - TYCameraProtocol
    
    - (UIViewController *)viewControllerWithDeviceId:(NSString *)devId uiName:(NSString *)uiName {
        
    }
    

Obtain preview panel

  • The old calling method is:

    #pragma mark - TuyaSmartCameraPanelSDK
    
    UIViewController *vc = [[TuyaSmartCameraPanelSDK sharedInstance] cameraViewControllerWithDeviceModel:deviceModel];
    [self.nav pushViewControllver:vc animated:YES];
    
  • Switch to the new calling method:

    id<TYCameraProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYCameraProtocol)];
    UIViewController *vc = [impl viewControllerWithDeviceId:self.deviceModel.devId uiName:self.device.uiName];
    [self.navigationController pushViewController:vc animated:YES];
    

Obtain or jump to other panel, please refer to the interface notes of the new business package TuyaSmartCameraPanelBizBundle.