Skip to content

Instantly share code, notes, and snippets.

@SongJiaqiang
Created April 27, 2018 08:20
Show Gist options
  • Save SongJiaqiang/a67e3070aff20759bc802f1454612231 to your computer and use it in GitHub Desktop.
Save SongJiaqiang/a67e3070aff20759bc802f1454612231 to your computer and use it in GitHub Desktop.
打开app在appstore的介绍页面
/** 跳转AppStore app */
- (void)goAppStore:(NSString *)appId {
if (!appId || appId.length == 0) {
logError(@">> TTAD: AppId不能为空");
return;
}
logInfo(@">> TTAD: 跳转到内置appstore页: %@", appId);
NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", appId];
NSURL *openURL = [NSURL URLWithString:urlStr];
if ([[UIApplication sharedApplication] canOpenURL:openURL]) {
[[UIApplication sharedApplication] openURL:openURL];
}
}
/**
* 跳转内置AppStore
* #import <StoreKit/StoreKit.h>
*/
- (void)goAppStoreInApp:(NSString *)appId
{
if (!appId || appId.length == 0) {
logError(@">> TTAD: AppId不能为空");
return;
}
logInfo(@">> TTAD: 跳转到内置appstore页: %@", appId);
SKStoreProductViewController *skStoreProductViewController = [[SKStoreProductViewController alloc] init];
NSDictionary *params = @{SKStoreProductParameterITunesItemIdentifier:appId};
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:skStoreProductViewController animated:YES completion:nil];
[skStoreProductViewController loadProductWithParameters:params completionBlock:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment