Last Updated on : 2025-11-17 06:52:22download
Group Management UI BizBundle provides the service logic and UI encapsulation for device groups. This allows users to create device groups, and control multiple devices of the same group in each request. You can use the UI BizBundle to implement multiple features. For example, create a group of devices that belong to the same type, and add devices to or delete them from groups.
Add the components of the Group Management 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 Group Management UI BizBundle
pod 'ThingSmartGroupHandleBizBundle'
end
The UI BizBundle relies on the implementation of the protocol ThingGroupHandleProtocol to provide services. In the ThingModuleServices component, you can view the ThingGroupHandleProtocol.h file. The following code block shows the protocol content:
```objc
typedef enum {
ThingGroupHandleTypeSupport,
ThingGroupHandleTypeNotSupport,
ThingGroupHandleTypeInvalid,
} ThingGroupHandleType;
@protocol ThingGroupHandleProtocol <NSObject>
/**
zh^
创建 Wi-Fi 标准或普通群组
zh$
en^
Create standard or common Wi-Fi groups.
en$
@param deviceId zh^ 设备 ID zh$ en^ device ID en$
@param completion zh^ 回调 zh$ en^ call back en$
*/
- (void)createWifiGroupWithDeviceId:(NSString *_Nonnull)deviceId completion:(void (^ _Nullable)(ThingGroupHandleType type))completion
__deprecated_msg("Use createGroup:completion: instead");
/**
zh^
编辑 Wi-Fi 标准或普通群组
zh$
en^
Modify standard or common Wi-Fi groups.
en$
@param groupId zh^ 群组 ID zh$ en^ group ID en$
@param completion zh^ 回调 zh$ en^ call back en$
*/
- (void)editWifiGroupWithGroupId:(NSString *_Nonnull)groupId completion:(void (^ _Nullable)(ThingGroupHandleType type))completion
__deprecated_msg("Use editGroup:completion: instead");
/**
zh^
创建群组。
zh$
en^
Create standard or common Wi-Fi groups.
en$
@param deviceId zh^ 设备ID zh$ en^ device ID en$
@param completion zh^ 回调 zh$ en^ call back en$
*/
- (void)createGroup:(NSString *_Nonnull)deviceId completion:(void (^ _Nullable)(ThingGroupHandleType type))completion;
/**
zh^
编辑群组
zh$
en^
Modify standard or common Wi-Fi groups.
en$
@param groupId zh^ 群组ID zh$ en^ group ID en$
@param completion zh^ 回调 zh$ en^ call back en$
*/
- (void)editGroup:(NSString *_Nonnull)groupId completion:(void (^ _Nullable)(ThingGroupHandleType type))completion;
@end
```
The UI BizBundle depends on the method provided by the protocol ThingFamilyProtocol. Before you call the UI BizBundle, you must implement the protocol ThingFamilyProtocol to provide the current home information required by the scene component.
ObjC:
#import <ThingSmartBizCore/ThingSmartBizCore.h>
#import <ThingModuleServices/ThingGroupHandleProtocol.h>
- (void)createGroup:(NSString *)deviceId completion:(void (^)(ThingGroupHandleType type))completion{
id <ThingGroupHandleProtocol> impl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingGroupHandleProtocol)];
[impl createGroup:deviceId completion:^(ThingGroupHandleType type) {
switch (type) {
case ThingGroupHandleTypeInvalid:
NSLog(@"DeviceId is invalid");
break;
case ThingGroupHandleTypeSupport:
NSLog(@"Support");
break;
case ThingGroupHandleTypeNotSupport:
NSLog(@"Not Support");
break;
default:
break;
}
}];
}
Swift:
func createGroup(deviceId: String, completion: @escaping (ThingGroupHandleType) -> Void) {
let groupImpl = ThingSmartBizCore.sharedInstance().service(of: ThingGroupHandleProtocol.self) as? ThingGroupHandleProtocol
groupImpl?.createGroup(deviceId, completion: { (type) in
switch type {
case ThingGroupHandleTypeInvalid :
print("DeviceId is invalid")
break
case ThingGroupHandleTypeSupport :
print("Support")
break
case ThingGroupHandleTypeNotSupport :
print("NotSupport")
break
default :
break
}
})
}
ObjC:
#import <ThingSmartBizCore/ThingSmartBizCore.h>
#import <ThingModuleServices/ThingGroupHandleProtocol.h>
- (void)editGroup:(NSString *)groupId completion:(void (^)(ThingGroupHandleType type))completion;{
id <ThingGroupHandleProtocol> impl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingGroupHandleProtocol)];
[impl editGroup:groupId completion:^(ThingGroupHandleType type) {
switch (type) {
case ThingGroupHandleTypeInvalid:
NSLog(@"DeviceId is invalid");
break;
case ThingGroupHandleTypeSupport:
NSLog(@"Support");
break;
case ThingGroupHandleTypeNotSupport:
NSLog(@"Not Support");
break;
default:
break;
}
}];
}
Swift:
func editGroup(groupId: String, completion: @escaping (ThingGroupHandleType) -> Void) {
let groupImpl = ThingSmartBizCore.sharedInstance().service(of: ThingGroupHandleProtocol.self) as? ThingGroupHandleProtocol
groupImpl?.editGroup(groupId, completion: { (type) in
switch type {
case ThingGroupHandleTypeInvalid :
print("DeviceId is invalid")
break
case ThingGroupHandleTypeSupport :
print("Support")
break
case ThingGroupHandleTypeNotSupport :
print("NotSupport")
break
default :
break
}
})
}
After a group is created, the group panel will open by default. If you need to customize the redirection logic, you can implement the ThingGroupHandleExtensionAPI interface. The interface is defined as follows:
@protocol ThingGroupHandleExtensionAPI <NSObject>
- (void)gotoGroupPanel:(ThingSmartGroupModel *)group;
@end
This interface is available in the version 6.11.0 of BizBundle.
class ThingGroupHandleExtensionAPIImpl: NSObject, ThingGroupHandleExtensionAPI {
func gotoGroupPanel(_ group: ThingSmartGroupModel) {
print("Custom group creation redirection");
}
}
// Usage
ThingSmartBizCore.sharedInstance().registerService(ThingGroupHandleExtensionAPI.self, with: ThingGroupHandleExtensionAPIImpl.self)
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback