iOS开发用如何用类"SKStoreProductViewController"跳转AppStore点赞评分?

 

大家都知道,评论评分是决定appappstore中排名的重要因素,但是大部分用户下载安装APP后却不会去点评,所以添加提示用户去点评的功能是很必要的。

目前,AppStore点赞评分有两种方法,一种是跳出应用,跳转到AppStore;进行评分.另一种是在应用内,内置AppStore进行评分.

序号方法备注
in:在应用,内置AppStore进行评分利用系统类:<br />SKStoreProductViewController
out:跳出应用,跳转到AppStore,进行评分利用方法:<br />[[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 : @"587767923"} 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:587767923;

方法二:跳出应用,跳转到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为自己appappid
代码:
-(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]];  
}

**注意: **
这个appID 是itunes connect里面你提交app 时候自动生成的,是apple的唯一的ID。方法二中:将appid链接中将xxxxxxx替换为54720389

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值