跳转到AppStore让用户能够给我们的应用进行评分,有两种方法,一种是跳出应用,跳转到AppStore,进行评分.另一种是在应用内,内置AppStore进行评分.
PS:appleID在https://itunesconnect.apple.com中创建应用即可在应用界面获得
1.跳出应用,跳转到AppStore,进行评分
如果是7.0以前的系统
NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=xxxxxx" ];
[[UIapplication sharedApplication] openURL:[NSURL URLWithString:str]];
如果是7.0以后的系统
NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/idxxxxxxx"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
2.在应用内,内置AppStore进行评分
苹果提供了一个框架StoreKit.framework,导入StoreKit.framework,在需要跳转的控制器里面添加头文件 #import <StoreKit/StoreKit.h>, 实现代理方法:< SKStorePRoductViewControllerDelegate >
//自定义方法
- (void)loadAppStoreController
{
// 初始化控制器
SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
// 设置代理请求为当前控制器本身
storeProductViewContorller.delegate = self;
[storeProductViewContorller loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:kAppId} completionBlock:^(BOOL result, NSError *error) {
if(error)
{
NSLog(@"error %@ with userInfo %@",error,[error userInfo]);
} else
{
// 模态弹出appstore
[self presentViewController:storeProductViewContorller animated:YES completion:^{
}];
}
}];
}
//AppStore取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:^{
}];
}