Last Updated on : 2023-06-05 02:41:22download
Access control supports the following capabilities:
Access control with passwords: The password of an access control device such as a smart lock can be sent to a specific email address. The user of the email address can use this password to unlock the door. Currently, only online passwords can be sent.
Members allowed for access: A specified user can be granted access permissions for a long time. The member allowed for access can only use the target access control device.
After login, an object of TuyaResidenceAccess
can be declared to call all object methods of this class.
- (TuyaResidenceAccess *)access {
if (!_access) {
_access = [[TuyaResidenceAccess alloc] init];
}
return _access;
}
API description
- (void)addAppAccessWithModel:(TuyaResidenceAddAppAccessModel *)appAccessModel
success:(TYSuccessBOOL)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
TuyaResidenceAddAppAccessModel | The request model to add an app user allowed for access. |
success | The success callback. |
failure | The failure callback. |
Data model of TuyaResidenceInvitationCreateRequestModel
Field | Type | Description |
---|---|---|
siteId | long long | The current site ID. |
account | NSString | The account of the member to be added. |
nickname | NSString | The nickname of a specified user. |
deviceIdList | NSArray<NSString *> | The list of devices. |
startTime | long | The 13-digit start timestamp for the validity period of the authorization. If the value is set to -1 , the authorization is permanently valid. |
endTime | long | The 13-digit end timestamp for the validity period of the authorization. If the value is set to -1 , the authorization is permanently valid. |
userType | TuyaResidenceAccessUserType | The type of member. Valid values:
userType is 30 can be created. The type of site is indicated by siteType of TuyaResidenceSiteModel . |
Example
Objective-C:
[self.access addAppAccessWithModel:reqModel success:^(BOOL result) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchAppAccessListWithSiteId:(long long)siteId
effective:(BOOL)effective
pageNo:(NSInteger)pageNo
pageSize:(NSInteger)pageSize
success:(void(^)(NSArray<TuyaResidenceAppAccessModel *> *userList))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
effective |
|
pageNo | The page number, starting from 1 and incremented by 1 for each request. |
pageSize | The number of entries to be returned per page. Valid values: 10 to 100 . |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchAppAccessListWithSiteId:siteId effective:YES pageNo:1 pageSize:20 success:^(NSArray<TuyaResidenceAppAccessModel *> * _Nonnull userList) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchAppAccessUserDetailWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
success:(void(^)(TuyaResidenceAppAccessDetailModel *userDetail))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchAppAccessUserDetailWithSiteId:siteId accessUserId:accessUserId success:^(TuyaResidenceAppAccessDetailModel * _Nonnull userDetail) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchAppAccessPassRecordWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
pageNo:(NSInteger)pageNo
pageSize:(NSInteger)pageSize
success:(void(^)(NSArray<TuyaResidenceAccessRecordModel *> *accessUserRecordList))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
accessUserId | The member ID. |
pageNo | The page number, starting from 1 and incremented by 1 for each request. |
pageSize | The number of entries to be returned per page. Valid values: 10 to 100 . |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchAppAccessPassRecordWithSiteId:siteId accessUserId:accessUserId pageNo:1 pageSize:20 success:^(NSArray<TuyaResidenceAccessRecordModel *> * _Nonnull accessUserRecordList) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchAppAccessTotalWithSiteId:(long long)siteId
effective:(BOOL)effective
success:(void(^)(NSInteger total))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
effective |
|
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchAppAccessTotalWithSiteId:siteId effective:effective success:^(NSInteger total) {
} failure:^(NSError *error) {
}];
API description
- (void)addAppAccessDeviceWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
deviceIdList:(NSArray<NSString *> *)deviceIdList
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
accessUserId | The member ID. |
deviceIdList | The list of target device IDs. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access addAppAccessDeviceWithSiteId:siteId accessUserId:accessUserId deviceIdList:deviceIdList success:^{
} failure:^(NSError *error) {
}];
API description
- (void)removeAppAccessDeviceWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
deviceId:(NSString *)deviceId
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
accessUserId | The member ID. |
deviceIdList | The list of target device IDs. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access removeAppAccessDeviceWithSiteId:siteId accessUserId:accessUserId deviceId:deviceId success:^{
} failure:^(NSError *error) {
}];
API description
- (void)removeAppAccessWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
accessUserId | The member ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access removeAppAccessWithSiteId:siteId accessUserId:accessUserId success:^{
} failure:^(NSError *error) {
}];
API description
- (void)updateAppAccessWithSiteId:(long long)siteId
accessUserId:(NSString *)accessUserId
nickName:(NSString *)nickName
userType:(TuyaResidenceAccessUserType)userType
startTime:(long)startTime
endTime:(long)endTime
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
accessUserId | The member ID. |
nickName | The nickname. |
userType | The type of member. Valid values:
userType is 30 can be created. |
startTime | The 13-digit start timestamp for the validity period of the authorization. If the value is set to -1 , the authorization is permanently valid. |
endTime | The 13-digit end timestamp for the validity period of the authorization. If the value is set to -1 , the authorization is permanently valid. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access updateAppAccessWithSiteId:siteId accessUserId:accessUserId nickName:nickname userType:userType startTime:startTime endTime:endTime success:^{
} failure:^(NSError *error) {
}];
API description
- (void)addPasswordAccessWithModel:(TuyaResidenceAddPasswordAccessModel *)requstModel
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
TuyaResidenceAddPasswordAccessModel | The request model to add a member allowed for access with a password. |
success | The success callback. |
failure | The failure callback. |
Data model of TuyaResidenceAddPasswordAccessModel
Field | Type | Description |
---|---|---|
siteId | long long | The site ID. |
deviceIdList | NSArray<NSString *> | The list of access control device IDs. |
passwordInfo | TuyaResidencePasswordInfoModel | The information about the password. |
userList | NSArray<TuyaResidencePasswordUserModel *> | The model of the member allowed for access with a password. |
Data model of TuyaResidencePasswordInfoModel
Field | Type | Description |
---|---|---|
passwordValue | NSString | The password. |
Data model of TuyaResidencePasswordUserModel
Field | Type | Description |
---|---|---|
nickname | NSString | The nickname. |
username | NSString | The account. |
Example
Objective-C:
[self.access addPasswordAccessWithModel:reqModel success:^{
} failure:^(NSError *error) {
}];
API description
- (void)fetchPasswordAccessListWithSiteId:(long long)siteId
effective:(BOOL)effective
pageNo:(NSInteger)pageNo
pageSize:(NSInteger)pageSize
success:(void (^)(NSArray<TuyaResidencePasswordAccessModel *> *accessPasswordList))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
effective |
|
pageNo | The page number, starting from 1 and incremented by 1 for each request. |
pageSize | The number of entries to be returned per page. Valid values: 10 to 100 . |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchPasswordAccessListWithSiteId:siteId effective:YES pageNo:1 pageSize:20 success:^(NSArray<TuyaResidencePasswordAccessModel *> * _Nonnull accessPasswordList) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchPasswordAccessUserDetailWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
success:(void (^)(TuyaResidencePasswordAccessModel *accessPasswordModel))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchPasswordAccessUserDetailWithSiteId:siteId authGroupId:authGroupId success:^(TuyaResidencePasswordAccessModel * _Nonnull accessPasswordModel) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchPasswordAccessPassRecordWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
pageNo:(NSInteger)pageNo
pageSize:(NSInteger)pageSize
success:(void(^)(NSArray<TuyaResidenceAccessRecordModel *> *accessUserRecordList))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
pageNo | The page number, starting from 1 and incremented by 1 for each request. |
pageSize | The number of entries to be returned per page. Valid values: 10 to 100 . |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchPasswordAccessPassRecordWithSiteId:siteId authGroupId:authGroupId pageNo:1 pageSize:20 success:^(NSArray<TuyaResidenceAccessRecordModel *> * _Nonnull accessUserRecordList) {
} failure:^(NSError *error) {
}];
API description
- (void)fetchPasswordAccessTotalWithSiteId:(long long)siteId
effective:(BOOL)effective
success:(void(^)(NSInteger total))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
effective |
|
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchPasswordAccessTotalWithSiteId:siteId effective:effective success:^(NSInteger total) {
} failure:^(NSError *error) {
}];
Removes a user allowed for access with a password from a device that must be online to receive the command. Otherwise, the user will fail to be removed. You can call [TuyaSmartDevice deviceWithDeviceId:deviceId]
to query device information, including its online status.
API description
- (void)removePasswordAccessWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access removePasswordAccessWithSiteId:siteId authGroupId:authGroupId success:^{
} failure:^(NSError *error) {
}];
Adds devices to users allowed for access with passwords. The device must be online to receive the command. Otherwise, the devices will fail to be added. You can call [TuyaSmartDevice deviceWithDeviceId:deviceId]
to query device information, including its online status.
API description
- (void)addPasswordAccessDeviceWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
deviceIdList:(NSArray<NSString *> *)deviceIdList
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
deviceIdList | The list of device IDs. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access addPasswordAccessDeviceWithSiteId:siteId authGroupId:authGroupId deviceIdList:deviceIdList success:^{
} failure:^(NSError *error) {
}];
Removes devices from users allowed for access with passwords. The devices must be online to receive the command. Otherwise, the devices will fail to be removed. You can call [TuyaSmartDevice deviceWithDeviceId:deviceId]
to query device information, including its online status.
API description
- (void)removePasswordAccessDeviceWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
deviceId:(NSString *)deviceId
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
deviceId | The device ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access removePasswordAccessDeviceWithSiteId:siteId authGroupId:authGroupId deviceId:deviceId success:^{
} failure:^(NSError *error) {
}];
API description
- (void)updatePasswordAccessValidityWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
doorPassword:(TuyaResidenceBasePasswordInfoModel *)doorPassword
deviceIdList:(NSArray<NSString *> *)deviceIdList
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
doorPassword | The model of the lock password. |
deviceIdList | The list of device IDs. |
success | The success callback. |
failure | The failure callback. |
Data model of TuyaResidenceBasePasswordInfoModel
Field | Type | Description |
---|---|---|
authType | TuyaResidencePasswordAuthType | The type of password. Valid values:
|
authName | NSString | The authorized name. |
effectiveTime | long | The 13-digit timestamp when the password becomes effective. |
invalidTime | long | The 13-digit timestamp when the password expires. |
scheduleRepeat | NSInteger | The type of schedule. Valid values:
|
schedule | TuyaResidencePasswordScheduleModel | When scheduleRepeat is set to 1 , this model is required. |
Data model of TuyaResidencePasswordScheduleModel
Field | Type | Description |
---|---|---|
startClock | NSInteger | The start time of a schedule. Example:
|
endClock | NSInteger | The end time of a schedule. Example: 21:00 is represented by 21 * 60 = 1260 . |
weekDay | NSInteger | The weekly recurring method represented by a 7-digit binary value. The recurring date is set to 1 . Otherwise, it is set to 0 . Then, the value is converted into a decimal value. For example, a schedule that recurs from Monday to Friday is represented by 1111100 that is converted into the decimal value 124 . |
Example
Objective-C:
[self.access updatePasswordAccessValidityWithSiteId:siteId authGroupId:authGroupId doorPassword:doorModel deviceIdList:deviceIdList success:^{
} failure:^(NSError *error) {
}];
API description
- (void)updatePasswordAccessNicknameWithSiteId:(long long)siteId
authGroupId:(NSString *)authGroupId
nickName:(NSString *)nickName
success:(TYSuccessHandler)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
authGroupId | The authorization group ID. |
nickName | The nickname. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access updatePasswordAccessNicknameWithSiteId:siteId authGroupId:authGroupId nickName:nickname success:^{
} failure:^(NSError *error) {
}];
API description
- (void)fetchDeviceListWithSiteId:(long long)siteId
success:(void(^)(NSArray<TuyaSmartDeviceModel *> *devices))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The current site ID. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access fetchDeviceListWithSiteId:model.siteId success:^(NSArray<TuyaSmartDeviceModel *> * _Nonnull devices) {
} failure:^(NSError *error) {
}];
API description
- (void)checkAccessAccountWithUserAccount:(NSString *)userAccount
success:(TYSuccessBOOL)success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
userAccount | The user account. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access checkAccessAccountWithUserAccount:username success:^(BOOL result) {
} failure:^(NSError *error) {
}];
Checks whether a user on a site is a member allowed for access, a site member, or an unregistered user.
API description
- (void)checkAccessAuthorizationWithSiteId:(long long)siteId
userAccount:(NSString *)userAccount
success:(void(^)(TuyaResidenceAccessMemberType result))success
failure:(TYFailureError)failure;
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
userAccount | The user account. |
success | The success callback. |
failure | The failure callback. |
Example
Objective-C:
[self.access checkAccessAuthorizationWithSiteId:siteId userAccount:userAccount success:^(TuyaResidenceAccessMemberType result) {
} failure:^(NSError *error) {
}];
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback