第一种方法:
NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=(这里填你的Apple ID)"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
第二种方法:
导入头文件 #import <StoreKit/StoreKit.h>
遵循代理协议 SKStoreProductViewControllerDelegate
- (void)jumpAppStore {
NSDictionary *dict = [NSDictionary dictionaryWithObject:@"这里填你的Apple ID" forKey:SKStoreProductParameterITunesItemIdentifier];
SKStoreProductViewController *vc = [[SKStoreProductViewController alloc] init];
vc.delegate=self;
// 1.先加载,加载成功再跳转到App Store
// [vc loadProductWithParameters:dict completionBlock:^(BOOL result, NSError * _Nullable error) {
// if(error) {
// NSLog(@"Error:%@",error.userInfo);
// }
// else {
// [self presentViewController:vc animated:YES completion:nil];
// }
// }];
// 2.先跳转到App Store,再加载数据
[self presentViewController:vc animated:YES completion:nil];
[vcloadProductWithParameters:dict completionBlock:^(BOOL result, NSError * _Nullable error) {
if(error) {
NSLog(@"Error:%@",error.userInfo);
}else{
}
}];
}
#pragma mark - SKStoreProductViewControllerDelegate
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[viewControllerdismissViewControllerAnimated:YES completion:^{
NSLog(@"productViewControllerDidFinish");
}];
}
网友评论