iOS之APP评分实现
2017-08-04 本文已影响0人
IOSCoderYummy
APP评分实现有两种方式:跳转到App Store进行评分和APP内评分
1.跳转到App Store进行评分
ps:appid可在iTunes connect里面查询
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=APPID&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8"]];
2.在自己app内,内置App Store评分。苹果提供了一个框架StoreKit.framework,导入StoreKit.framework,在需要跳转的控制器里面添加头文件#import, 实现代理方法:< SKStorePRoductViewControllerDelegate >
//加载App Store评分控制器
- (void)setUpAppStoreController
{
// 初始化控制器
SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
// 设置代理请求为当前控制器本身
storeProductViewContorller.delegate = self;
[storeProductViewContorller loadProductWithParameters: @{SKStoreProductParameterITunesItemIdentifier: kAppId} completionBlock:^(BOOLresult,NSError*error) {
if(error) {
NSLog(@"error %@ with userInfo %@",error,[erroruserInfo]);
}else{
// 模态弹出App Store评分控制器
[self presentViewController:storeProductViewContorller animated:YEScompletion:nil];
}
}];
}
//监听App Store取消按钮点击
- (void)productViewControllerDidFinish:(SKStoreProductViewController*)viewController
{
[self dismissViewControllerAnimated: YES completion: nil];
}