[ios6]앱스토어 모달로 불러오기
iOS6되면서부터 앱 안에서 URL스키마를 사용한
[[UIApplication sharedApplication] openURL:앱스토어 링크]
- (void)presentAppStoreForID:(NSNumber *)appStoreID inView:(UIView *)view withDelegate:(id<SKStoreProductViewControllerDelegate>)delegate withURL:(NSURL *)appStoreURL
{
if(NSClassFromString(@"SKStoreProductViewController")) { // iOS6 이상인지 체크
SKStoreProductViewController *storeController = [[SKStoreProductViewController alloc] init];
storeController.delegate = delegate; // productViewControllerDidFinish
NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier : appStoreID };
[storeController loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) {
if (result) {
[self presentViewController:storeController animated:YES completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:@"연결 실패" message:@"앱을 불러올 수 없습니다." delegate:nil cancelButtonTitle:@"확인" otherButtonTitles: nil] show];
}
}];
} else { // iOS6 이하일 때
[[UIApplication sharedApplication] openURL:appStoreURL];
}
}
// 닫을 때
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[viewController dismissModalViewControllerAnimated:YES];
}