先来说一下之前的去App Store打分评价的做法
- 使用连接跳转到App Store打分评价
NSString *iTunesLink = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=(app对应的App Store中的ID)&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
//解释一下相应的参数
//onlyLatestVersion:true 只针对最新的版本
//pageNumber:0 第一页显示的品论
//sortOrdering(0:默认进入的是APP详情 1:直接进入评论 3:直接进入相关)
- iOS6之后有了StoreKit可以在内部直接打开App Store(这种方法无法直接跳转到评价的item)进入的是默认的APP详情
1.创建一个SKStoreProductViewController
2.调用loadProductWithParameters:completionBlock:方法将APP对应的AppStoreID 参数传进去
3.实现代理方法 就可以跳AppStore
SKStoreProductViewController *productStore = [[SKStoreProductViewController alloc] init];
productStore.delegate = self;
[productStore loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"991552878"} completionBlock:^(BOOL result, NSError * _Nullable error) {
if (result) {
[self presentViewController:productStore animated:YES completion:^{
}];
}
else {
NSLog(@"error:%@, result:%d", error, result);
}
}];
//代理方法
#pragma mark - SKStoreProductViewControllerDelegate
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[self dismissViewControllerAnimated:YES completion:^{
}];
}
- iOS10.3之后,又增加了一个打分方法,仅仅是可以用来打分,无法评价,使用起来也非常的方便直接调用类方法接口即可
[SKStoreReviewController requestReview];//一行代码搞定
效果图(在APP内部进行App Store打分)
appstore 打分.png
我是这样使用的
//评分
- (void)loadAppStoreController {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.3) {
[SKStoreReviewController requestReview];
} else {
SKStoreProductViewController *productStore = [[SKStoreProductViewController alloc] init];
productStore.delegate = self;
[productStore loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"991552878"} completionBlock:^(BOOL result, NSError * _Nullable error) {
if (result) {
[self presentViewController:productStore animated:YES completion:^{
}];
}
else {
DLog(@"error:%@, result:%d", error, result);
}
}];
}
}
网友评论