Query Basic Pairing Data

Last Updated on : 2024-02-08 06:26:56download

This topic describes how to query a list of pairing data. It provides the capabilities to customize the pattern to display the returned list. You can customize the list page based on the pairing lists supported by the Tuya IoT Development Platform.

Functional description

You must call API methods in ThingSmartActivatorDiscoveryRequest to get information about the list views.

Integrate with the UI BizBundle

Add the components of the Voice Skills Account Linking UI BizBundle to the Podfile and run the command pod update.

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

target 'your_target_name' do
  pod 'ThingSmartActivatorDiscoveryManager'
end

Depend on services

None.

Query level-1 category for pairing

API description

/// Request a list of categories at the first level
/// @param param Request parameters
/// @param success Network success callback, return the corresponding first-level category information
/// @param failure Network failure callbacks
- (void)requestPrimaryCategoryWithParam:(ThingActivatorPrimaryCategoryRequestData *)param success:(void(^)(ThingSmartACategoryModel *result))success failure:(ThingActivatorCallbackError)failure;

Parameters

None.

Example for Objective-C

#import <ThingSmartActivatorDiscoveryManager/ThingSmartActivatorDiscoveryManager.h>
    self.requestService = [ThingSmartActivatorDiscoveryRequest new];
    ThingActivatorPrimaryCategoryRequestData *param = [[ThingActivatorPrimaryCategoryRequestData alloc] init];
    [self.requestService requestPrimaryCategoryWithParam:param success:^(ThingSmartACategoryModel * _Nonnull result) {
    } failure:failure];

Example for Swift:

   let requestService = ThingSmartActivatorDiscoveryRequest()
   let requestData =  ThingActivatorPrimaryCategoryRequestData()
   requestService.requestPrimaryCategory(withParam: requestData) { result in
        
   } failure: { error in
        
   }

Query level-2 category for pairing

API description

/// Request a list of secondary categories corresponding to primary categories
/// @param param Request parameters
/// @param success Network success callback, return the corresponding secondary category list
/// @param failure Network failure callbacks
- (void)requestSecondaryCategoryWithParam:(ThingActivatorSecondaryCategoryRequestData *)param success:(void(^)( NSArray <ThingSmartACategoryLevel2Model *>*result))success failure:(ThingActivatorCallbackError)failure;

Parameters

Name Parameter type Description
levelOneCode NSString The value of levelOneCode for the level-1 category.
type NSString The type of the level-1 category.

Example for Objective-C

#import<ThingSmartActivatorDiscoveryManager/ThingSmartActivatorDiscoveryManager.h>

self.requestService = [ThingSmartActivatorDiscoveryRequest new];
ThingActivatorSecondaryCategoryRequestData *param = [[ThingActivatorSecondaryCategoryRequestData alloc] init];
param.levelOneCode = levelOneCode;
param.type = type;
[self.requestService requestSecondaryCategoryWithParam:param success:^(NSArray<ThingSmartACategoryLevel2Model *> * _Nonnull result) {

} failure:^(NSError * _Nonnull error) {
        
}];

Example for Swift:

 let requestService = ThingSmartActivatorDiscoveryRequest()
 let requestData =  ThingActivatorSecondaryCategoryRequestData()
 requestData.levelOneCode = "levelOneCode"
 requestData.type = "type"
 requestService.requestSecondaryCategory(withParam: requestData) { result in
            
 } failure: { error in
            
 }

Query level-3 category for pairing

API description

/// Request a list of secondary categories corresponding to primary categories
/// @param param Request parameters
/// @param success Network success callback to return bootstrap details
/// @param failure Network failure callbacks
- (void)requestCategoryDetailWithParam:(ThingActivatorCategoryDetailRequestData *)param success:(void(^)(ThingSmartDeviceCategoryModel *result))success failure:(ThingActivatorCallbackError)failure;

Parameters

Name Parameter type Description
bizValue NSString The product ID or category ID.
bizType NSNumber The type of bizValue. Valid values:
  • 0: a category
  • 1: a product

Example for Objective-C

ThingActivatorCategoryDetailRequestData *param = [[ThingActivatorCategoryDetailRequestData alloc] init];
param.bizType = bizType;
param.bizValue = bizValue;

[self.requestService requestCategoryDetailWithParam:param success:^(ThingSmartDeviceCategoryModel * _Nonnull result) {

} failure:failure];

Example for Swift:

let requestService = ThingSmartActivatorDiscoveryRequest()
let requestData =  ThingActivatorCategoryDetailRequestData()
requestData.bizType = 1
requestData.bizValue = "productID"
requestService.requestCategoryDetail(withParam: requestData) { result in

} failure: { error in

}