In App


In App 는 3.7.13 버전 이상 부터 제공되며 기본 라이브러리에 포함되어 있다.

In App 은 앱 내에서 사용자가 의도에 따라 별도로 다운로드/삭제 되는 앱이며, 고객 사 에서 앱 배포 초기 시점에 다수의 대용량 비즈앱을 모두 다운로드 하여 네트워크에 트래픽 집중 되는 문제 그리고 특정 타깃에게만 지정된 비즈앱을 사용하게 하기 위한 요구사항에 의해 기획 / 설계 되었다.

In App 을 위해서 HSP 는 비즈앱의 타입을 재 정의 하여 requiredoptional 앱으로 구분하며, required 앱은 기존과 동일하게 다운로드 하고 optional 앱은 사용자가 필요에 의해 다운로드 요청 시에만 다운로드 하도록 설계되었다.

업데이트의 경우 optional 앱이 단말에 설치된 이후부터는 required 앱과 동일하게 동작 되도록 설계되었다.


getList

getList 는 서버에서 현재 업로드 된 In App 형태를 가지는 비즈앱 목록을 전달 받은 후 단말 내에 설치된 비즈앱의 정보를 디비에서 얻은 후 이 값들을 비교하여 In App 목록을 전달 받게 된다.

inapp-getlist.png

이때 전달 받는 In App 정보는 아이디, 크기, 해시, 버전, 설치 유무 등의 정보를 가진다.

NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:[self bizAppId] forKey:@"bizappId"];
[dict setObject:[self title] forKey:@"title"];
[dict setObject:[self version] forKey:@"version"];
[dict setObject:[self icon] forKey:@"icon"];
[dict setObject:[self visibility] forKey:@"visibility"];
[dict setObject:[self appDescription] forKey:@"appDescription"];
[dict setObject:[self version] forKey:@"version"];
[dict setObject:[self type] forKey:@"type"];
[dict setObject:self.fileSize forKey:@"fileSize"];
[dict setObject:[self hashCode] forKey:@"hashCode"];
[dict setObject:[NSNumber numberWithBool:isInstalled] forKey:@"isInstalled"];

Example

///////////////
// 3.10.18 이상
///////////////
let inapp = DAPInApp()
let param = DAPInAppGetListParam()
inapp.execute(with: param, completion: { (dict) in
   
}) { (resultError) in
   
}


///////////////
// 3.10.18 이하
///////////////
let inapp = DAPInApp()
let params = Array<Any>()
inapp.execute(withActionName: "getlist", params: params, completion: { (dict) in
   guard let resultDict = dict else {
       return
    }

}) { (resultError) in
   guard let error = resultError else {
       return
    }
}

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPInApp new];
DAPInAppGetListParam *infoParam = [DAPInAppGetListParam new];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
   NSString *deviceResult = [resultDict objectForKey:kDeviceResult];
    NSLog(@"deviceResult : %@", deviceResult);
} failure:^(NSError *error) {
    NSLog(@"error : %@", [error userInfo]);
}];


///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [HMPCommonUtil deviceAPIWithServiceName:kInApp];
[deviceAPI executeWithActionName:@"getlist" params:nil completion:^(NSDictionary *resultDict) {
   
} failure:^(NSError *error) {
   
}];

install

install 은 getList 로 전달 받은 In App 정보를 기준으로 지정된 위치에 앱을 다운로드 한 뒤 install (unzip) 하고 설치하고 올바르게 설치되었으면 디비에 정보를 남기게 된다. 만약 파일 다운로드가 실패 하였거나 install 이 제대로 이루어지지 않았다면 오류를 반환 한다.

inapp-install.png

Example

///////////////
// 3.10.18 이상
///////////////
let inapp = DAPInApp()
let param = DAPInAppInstallParam()
var info = Dictionary<String, Any>()
info["bizappId"] = "optional_bizapp"
info["title"] = "option"
info["version"] = "1.0.0"
info["isInstalled"] = NSNumber(booleanLiteral: false)

param.bizAppInfos = [info]
inapp.execute(with: param, completion: { (dict) in
   
}) { (resultError) in
   
}


///////////////
// 3.10.18 이하
///////////////
let inapp = DAPInApp()
var info = Dictionary<String, Any>()
info["bizappId"] = "optional_bizapp"
info["title"] = "option"
info["version"] = "1.0.0"
info["isInstalled"] = NSNumber(booleanLiteral: false)
let params = [info]
inapp.execute(withActionName: "install", params: params, completion: { (dict) in
   guard let resultDict = dict else {
       return
    }

}) { (resultError) in
   guard let error = resultError else {
       return
    }
}


///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPInApp new];
DAPInAppInstallParam *infoParam = [DAPInAppInstallParam new];
infoParam.bizAppInfos = @[infoDict];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
   NSString *deviceResult = [resultDict objectForKey:kDeviceResult];
    NSLog(@"deviceResult : %@", deviceResult);
} failure:^(NSError *error) {
    NSLog(@"error : %@", [error userInfo]);
}];

///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [HMPCommonUtil deviceAPIWithServiceName:kInApp];
[deviceAPI executeWithActionName:@"install" params:@[bizappInfoDict] completion:^(NSDictionary *resultDict) {
   
} failure:^(NSError *error) {
   
}];


uninstall

unstainll 은 단말에 설치된 In App 파일을 삭제 요청 한 뒤 올바르게 삭제 되었으면 삭제된 In App 의 아이디를 기준으로 디비 데이터를 삭제한다. uninstall 의 경우 로컬 정보만을 기준으로 동작하므로 서버 (Operations) 와의 연동 작업은 별도로 존재하지 않는다.

inapp-uninstall.png

Example

///////////////
// 3.10.18 이상
///////////////
let inapp = DAPInApp()
let param = DAPInAppUnInstallParam()
var info = Dictionary<String, Any>()
info["bizappId"] = "optional_bizapp"
info["title"] = "option"
info["version"] = "1.0.0"
info["isInstalled"] = NSNumber(booleanLiteral: true)

param.bizAppInfos = [info]
inapp.execute(with: param, completion: { (dict) in
   
}) { (resultError) in
   
}



///////////////
// 3.10.18 이하
///////////////a
let inapp = DAPInApp()
var info = Dictionary<String, Any>()
info["bizappId"] = "optional_bizapp"
info["title"] = "option"
info["version"] = "1.0.0"
info["isInstalled"] = NSNumber(booleanLiteral: true)
let params = [info]
inapp.execute(withActionName: "uninstall", params: params, completion: { (dict) in
   guard let resultDict = dict else {
       return
    }

}) { (resultError) in
   guard let error = resultError else {
       return
    }
}

///////////////
// 3.10.18 이상
///////////////
DAPDeviceAPI *deviceAPI = [DAPInApp new];
DAPInAppUnInstallParam *infoParam = [DAPInAppUnInstallParam new];
infoParam.bizAppInfos = @[infoDict];
[deviceAPI executeWithParam:infoParam completion:^(NSDictionary *resultDict) {
   NSString *deviceResult = [resultDict objectForKey:kDeviceResult];
    NSLog(@"deviceResult : %@", deviceResult);
} failure:^(NSError *error) {
    NSLog(@"error : %@", [error userInfo]);
}];



///////////////
// 3.10.18 이하
///////////////
DAPDeviceAPI *deviceAPI = [HMPCommonUtil deviceAPIWithServiceName:kInApp];
[deviceAPI executeWithActionName:@"uninstall" params:@[bizappInfoDict] completion:^(NSDictionary *resultDict) {
   
} failure:^(NSError *error) {
   
}];