Created
April 27, 2018 08:20
-
-
Save SongJiaqiang/a67e3070aff20759bc802f1454612231 to your computer and use it in GitHub Desktop.
打开app在appstore的介绍页面
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 跳转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