更新时间:2024-06-11 08:20:53下载pdf
本文介绍如何管理密码。关于密码的更多信息,参考 商业门锁 SDK 概述。
接口说明
- (void)getPasswordListWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
pageNumber:(NSInteger)pageNumber
pageSize:(NSInteger)pageSize
success:(ThingLockPasswordSuccessList)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
pageNumber | 页码 |
pageSize | 每页数量 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared getPasswordListWithSiteId:siteId
deviceId:self.devId
pageNumber:1
pageSize:20
success:^(NSArray<ThingLockPasswordModel *> * _Nullable list, NSInteger totalSize) {
} failure:^(NSError *error) {
}];
接口说明
- (void)createOnceOfflinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
name:(NSString *)name
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
name | 密码名称 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared createOnceOfflinePasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
name:alertC.textFields.firstObject.text
success:^{
} failure:^(NSError *error) {
}];
接口说明
注意:设备需要在线,才能创建永久在线密码。
- (void)createPermanentOnlinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
password:(NSString *)password
name:(NSString *)name
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
password | 密码 |
name | 密码名称 |
success | 成功回调 |
failure | 失败回调 |
示例代码
关于如何连接设备,查看 门锁管理-连接门锁。
[ThingLockPasswordManager.shared createPermanentOnlinePasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
name:alertC.textFields.firstObject.text
success:^{
} failure:^(NSError *error) {
}];
PasswordBean
对象的 keyStatus
进行状态判断。如果遇到创建状态值为 CREATE_FAIL
时,可通过 retryCreateOnlinePassword
方法进行补偿创建。接口说明
- (void)createLimitOfflinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
name:(NSString *)name
effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
name | 密码名称 |
effectiveTimeInterval | 生效时间的整点时间戳,单位秒。例如 15:32,则传入 15:00 的时间戳 |
invalidTimeInterval | 失效时间的整点时间戳,单位秒。例如 18:24,则传入 18:00 的时间戳 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared createLimitOfflinePasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
name:self.passwordNameLabel.text
effectiveTimeInterval:effectiveTime
invalidTimeInterval:invalidTime
success:^{
} failure:^(NSError *error) {
}];
接口说明
设备需要在线,才能创建限时在线密码。
- (void)createLimitOnlinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
password:(NSString *)password
name:(NSString *)name
effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
workingDay:(NSString *)workingDay
startTime:(NSString *)startTime
endTime:(NSString *)endTime
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
password | 密码 |
name | 密码名称 |
effectiveTimeInterval | 生效时间的整点时间戳,单位秒。例如 15:32,则传入 15:00 的时间戳 |
invalidTimeInterval | 失效时间的整点时间戳,单位秒。例如 18:24,则传入 18:00 的时间戳 |
workingDay | 循环模式,例如 1011111 ,从周日开始到周一。如果是 1 则表示循环,0 则表示不循环 |
startTime | 开始时间,例如 7:00 |
endTime | 结束时间,例如 19:00 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared createLimitOnlinePasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
name:self.passwordNameLabel.text
effectiveTimeInterval:effectiveTime
invalidTimeInterval:invalidTime
workingDay:workingDay
startTime:startMinute
endTime:endMinute
success:^{
[self dismissViewControllerAnimated:YES completion:NULL];
[NSNotificationCenter.defaultCenter postNotificationName:@"UpatePasswordList" object:nil];
} failure:^(NSError *error) {
}];
PasswordBean
对象的 keyStatus
进行状态判断。如果遇到创建状态值为 CREATE_FAIL
时,可通过 retryCreateOnlinePassword
方法进行补偿创建。接口说明
- (void)removeOnceOfflinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared removeOnceOfflinePasswordWithSiteId:siteId
deviceId:self.devId
passwordId:passwordId
success:^{
} failure:^(NSError *error) {
}];
接口说明
设备需要在线,否则永久在线密码将删除失败。
- (void)removeOnlinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
lockId:(NSString *)lockId
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
lockId | 写入到门锁设备的虚拟 ID,从密码详情中获取 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared removeOnceOfflinePasswordWithSiteId:siteId
deviceId:self.devId
passwordId:passwordId
success:^{
} failure:^(NSError *error) {
}];
接口说明
- (void)removeLimitOfflinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
success:(ThingSuccessString)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared removeLimitOfflinePasswordWithSiteId:siteId
deviceId:self.devId
passwordId:passwordId
success:^(NSString *result) {
} failure:^(NSError *error) {
}];
当删除限时离线密码的时候,在回调中会得到一个清除码。用户需要在门锁设备中输入该清除码,才能真正清除该密码。
接口说明
设备需要在线,否则限时在线密码将删除失败。
- (void)removeOnlinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
lockId:(NSString *)lockId
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
lockId | 门锁 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
通过密码详情可以获取 lockId
。
[ThingLockPasswordManager.shared removeOnceOfflinePasswordWithSiteId:siteId
deviceId:self.devId
passwordId:passwordId
success:^{
} failure:^(NSError *error) {
}];
接口说明
- (void)getPasswordDetailWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
success:(ThingLockPasswordSuccess)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared getPasswordDetailWithSiteId:siteId
deviceId:self.devId
passwordId:self.password_id
success:^(ThingLockPasswordModel * _Nullable passwordModel) {
} failure:^(NSError *error) {
}];
接口说明
- (void)modifyPasswordSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
passwordName:(NSString *)passwordName
success:(ThingSuccessID)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
passwordName | 密码名称 |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared modifyPasswordSiteId:SiteManager.shared.siteId
deviceId:self.devId
passwordId:self.passwordModel.passwordId
passwordName:self.passwordModel.passwordName success:^(id result) {
} failure:^(NSError *error) {
}];
接口说明
- (void)forceRemoveOnlinePasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
passwordId:(NSString *)passwordId
success:(ThingSuccessID)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
deviceId | 设备 ID |
passwordId | 密码 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
[ThingLockPasswordManager.shared forceRemoveOnlinePasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
passwordId:passwordId
success:^(id result) {
} failure:^(NSError *error) {
}];
removeOnlinePassword
正常移除时,可以通过该方法强制移除该密码。接口说明
- (void)clearAllPasswordWithSiteId:(long long)siteId
deviceId:(NSString *)deviceId
success:(ThingSuccessHandler)success
failure:(ThingFailureError)failure;
参数说明
参数 | 说明 |
---|---|
siteId | 站点 ID |
lockDevId | 门锁设备 ID |
callback | 结果回调 |
示例代码
[ThingLockPasswordManager.shared clearAllPasswordWithSiteId:SiteManager.shared.siteId
deviceId:self.devId
success:^{
} failure:^(NSError *error) {
}];
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈