OTA UI BizBundle

Last Updated on : 2023-09-19 03:01:04download

An over-the-air (OTA) update enables automatic firmware download and updates over the network. OTA UI BizBundle helps you quickly integrate with firmware update capabilities.

Integrate with the UI BizBundle

Add the components of the OTA UI BizBundle to the Podfile and run the command pod update.

source "https://github.com/tuya/tuya-pod-specs"
source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'

target 'your_target_name' do
  # Adds the UI BizBundle.
  pod 'ThingSmartOTABizBundle'

To support OTA updates for Bluetooth devices, add the following permission declaration to info.plist of your project:


Service protocols


The UI BizBundle relies on the implementation of the protocol ThingOTAGeneralProtocol to provide services. You can view the file ThingOTAGeneralProtocol.h in the component ThingModuleServices.

#import <Foundation/Foundation.h>

@class ThingSmartDeviceModel;

typedef NS_ENUM(NSUInteger, ThingOTAControllerTheme) {

@protocol ThingOTAGeneralProtocol <NSObject>

 Checks whether the current device supports OTA firmware updates.

 @param deviceModel The device that checks for firmware updates.
 `YES`: supported
 `NO`: not supported
- (BOOL)isSupportUpgrade:(ThingSmartDeviceModel *)deviceModel;

 Checks for device firmware updates, and if any, shows the update prompt.

 @param deviceModel The device that checks for firmware updates.
 @param isManual Specifies whether to enable manual checking of firmware updates.
  @param theme The theme color.
 YES: Manually check for updates. A loading dialog box appears during the check. If a new update is found (check for updates, forced updates, and update notifications), OTA VC is displayed.
 NO: Automatically check for updates. A loading dialog box does not appear during the check. When forced updates and update notifications are enabled, the firmware update prompt appears. Click OK to show OTA VC.
- (void)checkFirmwareUpgrade:(ThingSmartDeviceModel *)deviceModel isManual:(BOOL)isManual theme:(ThingOTAControllerTheme)theme;



To customize the callback that is executed after the forced update is canceled (default logic is implemented by popToRootViewController), you must implement the protocol method provided by ThingOTAGeneralExternalProtocol.

@protocol ThingOTAGeneralExternalProtocol <NSObject>

/// @brief Customizes the callback that is executed when a forced update is canceled.
/// 1. During a forced update, tap Cancel in the dialog box to cancel the update.
/// 2. During a forced update, tap Back of `navigationBar`. If the update progress dialog box appears, tap OK.
/// @return `YES`: Custom callback. `NO`: default logic. `[self.navigationController popToRootViewControllerAnimated:YES]`
- (BOOL)didTapCancelForceUpgrade;


Usage instruction

Before the call of any API method, make sure that the user has logged in to the app.

Check for update and access the firmware update page


#import <ThingModuleServices/ThingModuleServices.h>
#import <ThingSmartBizCore/ThingSmartBizCore.h>

+ (void)test:(ThingSmartDeviceModel *)device {
    id<ThingOTAGeneralProtocol> otaImp = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingOTAGeneralProtocol)];

    if ([otaImp isSupportUpgrade:device]) {
        [otaImp checkFirmwareUpgrade:device isManual:YES theme:ThingOTAControllerWhiteTheme];
    } else {


func test(_ deviceModel: ThingSmartDeviceModel) {
	guard let otaImp = ThingSmartBizCore.sharedInstance().service(of: ThingOTAGeneralProtocol.self) as? ThingOTAGeneralProtocol else { return }

	if otaImp.isSupportUpgrade(deviceModel) {
		otaImp.checkFirmwareUpgrade(deviceModel, isManual: true, theme: .whiteTheme)
	} else {

Customize the callback for canceling forced update

After a forced update is canceled, [self.navigationController popToRootViewControllerAnimated:YES] is called by default. To customize the callback, you must register and implement ThingOTAGeneralExternalProtocol.

Objective-C: Register [ThingOTAObjcDemo registerService]; when needed.

#import <ThingModuleServices/ThingModuleServices.h>
#import <ThingSmartBizCore/ThingSmartBizCore.h>

@interface ThingOTAObjcDemo () <ThingOTAGeneralExternalProtocol>

@implementation ThingOTAObjcDemo

/// Registers the protocol.
+ (void)registerService {
    [[ThingSmartBizCore sharedInstance] registerService:@protocol(ThingOTAGeneralExternalProtocol) withInstance:self];

/// Implements the protocol.
#pragma mark - ThingOTAGeneralExternalProtocol -
- (BOOL)didTapCancelForceUpgrade {
    return YES;


Swift: Register OTASwiftDemo.registerService() when needed.

import Foundation

class OTASwiftDemo: NSObject, ThingOTAGeneralExternalProtocol {
    func registerService() {
        ThingSmartBizCore.sharedInstance().registerService(ThingOTAGeneralExternalProtocol.self, withInstance: self)

    // MARK: - ThingOTAGeneralExternalProtocol -
    func didTapCancelForceUpgrade() -> Bool {
        return true