English
English
简体中文
Register
Log In
English
English
简体中文
Register
Log In
Language
English
English
简体中文
Register
Log In

How to listen to the object home of ThingSmartHome when it switches?

Last Updated on2025-02-28 07:17:26
Example as follows:
- (void)viewDidLoad {
[super viewDidLoad];
// Monitor whether the home has been switched
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(homeIdDidChangedTest) name:@"kThingTPNotificationHomeIdDidChanged" object:nil];
}
- (void)homeIdDidChangedTest {
NSLog(@"\n== The home has been switched");
id<ThingFamilyProtocol> familyImpl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingFamilyProtocol)];
ThingSmartHome *home = [ThingSmartHome homeWithHomeId:[familyImpl currentFamilyId]];
NSLog(@"\n== The current home is: %@" , home.homeModel.name );
}

Click for services and help

Help Center