iOS6되면서부터 앱 안에서 URL스키마를 사용한


앱스토어로 링크가 아닌

앱 안에서 바로 앱스토어를 불러올 수 있습니다

iOS6 이전에는 

[[UIApplication sharedApplication] openURL:앱스토어 링크]

이렇게 앱스토어로 링크가 되어 앱이 전환되었습니다

iOS6에서는 앱 전환없이 자신의 앱 안에서 앱스토어를 불러올 수 있습니다.

1. StoreKit.framework 라이브러리를 추가해줍니다 
2. 헤더파일에 #import <StoreKit/SKStoreProductViewController.h>를 추가합니다
3. SKStoreProductViewControllerDelegate 델리게이트를 추가해줍니다

[self presentAppStoreForID:[NSNumber numberWithInt:앱아이디] inView:띄울 부모뷰(self.view) withDelegate:self withURL:[NSURL URLWithString:iOS6 이전 버전에 사용할 앱스토어 링크]];



- (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];

}


이런식으로 사용하시면

앱 안에서 앱스토어가 뜨는 신기한 광경*_*을 보실수가 있습니다.
이로인해 많은 변화가 있을거라 봅니다
앱안에서 구매, 리뷰, 스샷 다 가능하기 때문에 인앱을 넣을 필요가 없습니다!!
프리버젼올릴때 정말 좋습니다*_*
게다가 자신이 만든 다른 앱들도 홍보할 수가 있습니다!! ( -> 자신이 만든앱이 아니면 리젝됩니다 조심합시다)

많이 많이 사용합니다*_*
      
Posted by k_ben