Contact
Contact 는 HSP 에서 기본으로 제공하는 API로 별도의 설정 없이 사용 가능하며 연락처 정보를 추가하거나 불러오는 기능을 제공한다.
add
add 는 주소록 정보를 추가하는 기능이다. 이때 사용자 이름, 이메일주소, 전화번호를 입력할 수 있다.
AddContact
파라미터 | 설명 |
---|---|
firstName | 이름 |
lastName | 성 |
이메일 주소 | |
mobile | 핸드폰 번호 |
work | 회사 전화 번호 |
home | 집 전화 번호 |
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactAddParam()
infoParam.firstName = contactInfo.object(forKey: "firstName") as? String
infoParam.lastName = contactInfo.object(forKey: "lastName") as? String
infoParam.email = contactInfo.object(forKey: "email") as? String
infoParam.mobile = contactInfo.object(forKey: "mobile") as? String
infoParam.work = contactInfo.object(forKey: "work") as? String
infoParam.home = contactInfo.object(forKey: "home") as? String
deviceAPI.execute(with: infoParam, completion: { (dict) in
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let params = [contactInfo] as [Any]
deviceAPI.execute(withActionName: "add", params: params, completion: { (dict) in
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactAddParam()
infoParam.firstName = contactInfo.object(forKey: "firstName") as? String
infoParam.lastName = contactInfo.object(forKey: "lastName") as? String
infoParam.email = contactInfo.object(forKey: "email") as? String
infoParam.mobile = contactInfo.object(forKey: "mobile") as? String
infoParam.work = contactInfo.object(forKey: "work") as? String
infoParam.home = contactInfo.object(forKey: "home") as? String
deviceAPI.execute(with: infoParam, completion: { (dict) in
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let params = [contactInfo] as [Any]
deviceAPI.execute(withActionName: "add", params: params, completion: { (dict) in
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactAddParam *infoParam = [DAPContactAddParam new];
infoParam.firstName = [contactInfo objectForKey:@"firstName"];
infoParam.lastName = [contactInfo objectForKey:@"lastName"];
infoParam.email = [contactInfo objectForKey:@"email"];
infoParam.mobile = [contactInfo objectForKey:@"mobile"];
infoParam.work = [contactInfo objectForKey:@"work"];
infoParam.home = [contactInfo objectForKey:@"home"];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_added", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:
@"길동", @"firstName",
@"홍", @"lastName",
@"hong@gmail.com", @"email",
@"02-666-5555", @"home",
@"032-123-4567", @"work",
@"010-8521-2589", @"mobile",
nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"add" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactAddParam *infoParam = [DAPContactAddParam new];
infoParam.firstName = [contactInfo objectForKey:@"firstName"];
infoParam.lastName = [contactInfo objectForKey:@"lastName"];
infoParam.email = [contactInfo objectForKey:@"email"];
infoParam.mobile = [contactInfo objectForKey:@"mobile"];
infoParam.work = [contactInfo objectForKey:@"work"];
infoParam.home = [contactInfo objectForKey:@"home"];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"textResultDlg" resultObject:NSLocalizedString(@"app_result_added", nil)];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSDictionary *dictInfo = [NSDictionary dictionaryWithObjectsAndKeys:
@"길동", @"firstName",
@"홍", @"lastName",
@"hong@gmail.com", @"email",
@"02-666-5555", @"home",
@"032-123-4567", @"work",
@"010-8521-2589", @"mobile",
nil];
NSArray *params = [NSArray arrayWithObjects:dictInfo, nil];
[deviceAPI executeWithActionName:@"add" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
find
find 는 등록되어 있는 주소록에 전화번호, 이름, 이메일 주소를 이용하여 원하는 주소록을 얻을 수 있다.
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactFindParam()
infoParam.filterDisplayName = true
infoParam.filterPhoneNumbers = true
infoParam.filterEmail = true
infoParam.searchWord = contactInfo.object(forKey: "firstName") as? String
deviceAPI.execute(with:infoParam, completion: { (dict) in
guard let resultDict = dict else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let field = "phoneNumbers, displayName, email"
let filter = contactInfo.object(forKey: "firstName") as Any
let params = [field, filter] as [Any]
deviceAPI.execute(withActionName: "find", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactFindParam()
infoParam.filterDisplayName = true
infoParam.filterPhoneNumbers = true
infoParam.filterEmail = true
infoParam.searchWord = contactInfo.object(forKey: "firstName") as? String
deviceAPI.execute(with:infoParam, completion: { (dict) in
guard let resultDict = dict else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let field = "phoneNumbers, displayName, email"
let filter = contactInfo.object(forKey: "firstName") as Any
let params = [field, filter] as [Any]
deviceAPI.execute(withActionName: "find", params: params, completion: { (dict) in
guard let resultDict = dict else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactFindParam *infoParam = [DAPContactFindParam new];
infoParam.filterDisplayName = YES;
infoParam.filterPhoneNumbers = YES;
infoParam.filterEmail = YES;
infoParam.searchWord = [contactInfo objectForKey:@"firstName"];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"contactResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSString *field = @"phoneNumbers, displayName, email";
NSString *filter = @"홍";
NSArray *params = [NSArray arrayWithObjects:field, filter, nil];
[deviceAPI executeWithActionName:@"find" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactFindParam *infoParam = [DAPContactFindParam new];
infoParam.filterDisplayName = YES;
infoParam.filterPhoneNumbers = YES;
infoParam.filterEmail = YES;
infoParam.searchWord = [contactInfo objectForKey:@"firstName"];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
ResultData *resultData = [ResultData resultDataWithType:@"contactResultDlg" resultObject:[resultDict objectForKey:kDeviceResult]];
[self showSuccessDlgWithResultData:resultData];
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSString *field = @"phoneNumbers, displayName, email";
NSString *filter = @"홍";
NSArray *params = [NSArray arrayWithObjects:field, filter, nil];
[deviceAPI executeWithActionName:@"find" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
remove
remove 는 등록되어 있는 주소록을 삭제하는 기능이다. 삭제할 기준 값은 find 를 통해 얻은 id 값으로 삭제 할 수 있다.
Example
///////////////
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactRemoveParam()
infoParam.identifier = key
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let completed = completion else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let params = [key] as [Any]
deviceAPI.execute(withActionName: "remove", params: params, completion: { (dict) in
guard let completed = completion else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
// 3.10.18 이상
///////////////
let deviceAPI = DAPContact()
let infoParam = DAPContactRemoveParam()
infoParam.identifier = key
deviceAPI.execute(with: infoParam, completion: { (dict) in
guard let completed = completion else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이하
///////////////
let deviceAPI = DAPContact()
let params = [key] as [Any]
deviceAPI.execute(withActionName: "remove", params: params, completion: { (dict) in
guard let completed = completion else {
return
}
}, failure: { (resultError) in
guard let error = resultError else {
return
}
})
///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactRemoveParam *infoParam = [DAPContactRemoveParam new];
infoParam.identifier = key;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
if (completion == nil) {
return;
}
completion(resultDict);
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSString *removeId = @"123";
NSArray *params = [NSArray arrayWithObjects:removeId, nil];
[deviceAPI executeWithActionName:@"find" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
DAPContactRemoveParam *infoParam = [DAPContactRemoveParam new];
infoParam.identifier = key;
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
if (completion == nil) {
return;
}
completion(resultDict);
} failure:^(NSError *error) {
[self showErrorDlgWithError:error];
}];
///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [DAPContact new];
NSString *removeId = @"123";
NSArray *params = [NSArray arrayWithObjects:removeId, nil];
[deviceAPI executeWithActionName:@"find" params:params completion:^(NSDictionary *resultDict) {
NSLog(@"%s %d\nresultDict %@", __PRETTY_FUNCTION__, __LINE__, resultDict);
} failure:^(NSError *error) {
NSLog(@"%s %d\nerror %@", __PRETTY_FUNCTION__, __LINE__, error);
}];