iOS开发利用"SKStoreProductViewController"跳转AppStore点赞评
大家都知道,评论和评分是决定app在appstore中排名的重要因素,但是大部分用户下载安装APP后却不会去点评,所以添加提示用户去点评的功能是很必要的。
目前,AppStore点赞评分有两种方法,一种是跳出应用,跳转到AppStore;进行评分.另一种是在应用里内置AppStore进行评分.
| 序号 | 方法 | 备注 |
|---|---|---|
| ① |
in:在应用里内置AppStore进行评分 |
利用系统类:SKStoreProductViewController
|
| ② |
out:跳出应用,跳转到AppStore,进行评分 |
利用方法:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]
|
方法一:在应用内,内置AppStore进行评分
1、添加依赖 #import<StoreKit/StoreKit.h>
2、添加代理 <SKStoreProductViewControllerDelegate>
3、添加代码:调用跳转方法 [self thumbsUpWithAppStore];
- (void)thumbsUpWithAppStore {
SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
//设置代理请求为当前控制器本身
storeProductViewContorller.delegate = self; //加载一个新的视图展示
[storeProductViewContorller loadProductWithParameters: //appId唯一的
[SKStoreProductParameterITunesItemIdentifier : @"自己平台的appid"} completionBlock:^(BOOL result, NSError *error) { //block回调
if(error){
NSLog(@"error %@ with userInfo %@",error,[error userInfo]);
}else{ //模态弹出appstore
[self presentViewController:storeProductViewContorller animated:YES completion:^{
}];
}
}];
}
遵循代理SKStoreProductViewControllerDelegate:取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
[self dismissViewControllerAnimated:YES completion:^{
}];
}
注意:appId是唯一的,
appleID在 https://itunesconnect.apple.com 中创建应用即可在应用界面获得
即不同的app不同的appid,请用自己工程的appid。
**注意: **
这个appID 是itunes connect里面你提交app 时候自动生成的,是apple的唯一的ID。方法二中:将appid链接中将xxxxxxx替换为自己应用appid。
方法二:跳出应用,跳转到AppStore,进行评分
App Store上评论的链接地址有二种,分为iOS7前后链接:
| 分类 | 链接 | 说明 |
|---|---|---|
iOS7之前链接 |
itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id = xxxxxxxx |
其中xxxxxxxx为自己app的aped
|
iOS7之后链接 |
itms-apps://itunes.apple.com/app/idxxxxxxxxx |
其中xxxxxxxx为自己app的appid
|
代码:
-(void)goToAppStore
{
如果是7.0以前的系统
NSString *str = [NSString stringWithFormat: @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d",547203890];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
如果是7.0以后的系统
NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id547203890"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}