Key Examples

Last Updated on : 2024-06-18 08:18:27download

The Smart Lock SDK provides live streaming and two-way talk features for Wi-Fi locks.

Live streaming and two-way talk

Demo Class Method Description
ThingSmartWiFiLockDevice - (void)startPreviewWithDefinition :success:failure; Start live streaming.
ThingSmartWiFiLockDevice - (void)stopPreview; Stop live streaming.
ThingSmartWiFiLockDevice - (void)startTalk;
- (void)stopTalk;
Turn on/off two-way talk.

Destroy the allocated resource if a feature is not used. This helps to avoid possible errors. Get the ThingSmartWi-FiLockDevice object and call stopPreview, stopTalk, or dealloc to release the resource.

Example

Live streaming request

// Initialize
self.lockDevice = [[ThingSmartWi-FiLockDevice alloc] initWithDeviceId:self.device.deviceModel.devId];
//Set delegate
self.lockDevice.delegate = self;

[self.lockDevice startPreviewWithDefinition:0x2
     //TODO
  } failure:^(NSError *error) {
    //TODO
}];

[self.lockDevice stopPreview];

Two-way talk request

///Event Handler
- (void)buttonClick_StartTalk:(id)sender {
    BOOL isTalking = [self.lockDevice isTalking];
    BOOL isSupportedTalk = [self.lockDevice isSupportedTalk];

    if(!isTalking && isSupportedTalk){
        [self.lockDevice startTalk];
    }
}

- (void)dealloc {
   [self.lockDevice stopTalk];
}