设为首页 加入收藏

TOP

iOS开发用如何用类"SKStoreProductViewController"跳转AppStore点赞评分?
2019-09-18 11:12:27 】 浏览:67
Tags: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

 

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Unity 4.7 导出工程在XCode9/10上.. 下一篇基于Moya、RxSwift和ObjectMapper..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目