简体   繁体   English

iOS:在我的App中启动AppStore页面

[英]iOS: Launch AppStore page within my App

I seen games like Kingdom Clash Castle Story 我看过《王国冲突城堡物语》等游戏

being able to launch AppStore within their game without minimizing their game. 能够在游戏中启动AppStore而不会最小化他们的游戏。 The AppStore page will just slide in from bottom, show a game page, and players can download that game, key in their password, close the page and they are still in the game. AppStore页面将从底部滑入,显示游戏页面,玩家可以下载该游戏,输入密码,关闭页面,然后他们仍在游戏中。

Is there a way to do this? 有没有办法做到这一点? I can only minimize my own app, and open the Appstore. 我只能最小化自己的应用程序,然后打开Appstore。

Please advise. 请指教。 Thanks 谢谢

You can use SKStoreProductViewController class 您可以使用SKStoreProductViewController类

Import StoreKit framework 导入StoreKit框架

#import <StoreKit/StoreKit.h>

Implement the SKStoreProductViewControllerDelegate 实现SKStoreProductViewControllerDelegate

@interface MyViewControllerClass : NSObject <SKStoreProductViewControllerDelegate> {
}

- (void) openAppStore
{
    if( NSStringFromClass([SKStoreProductViewController class]) != nil )
    {
        SKStoreProductViewController *viewCont = [[SKStoreProductViewController alloc] init];
        viewCont.delegate = self;
        [viewCont loadProductWithParameters:[NSDictionary dictionaryWithObject:@"APP_ID_FROM_ITUNES" forKey:SKStoreProductParameterITunesItemIdentifier] completionBlock:nil];
        [self.navigationController presentViewController:viewCont animated:YES completion:nil];
    }
    else
    {
        // open safari
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/facebook/id284882215?mt=8"]];
    }
}


// SKStoreProductViewControllerDelegate
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)productViewController
{
    [productViewController dismissViewControllerAnimated:YES completion:nil];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM