iOS 在应用内展示App Store 评分

女神
导入:#import <StoreKit/StoreKit.h>
签订代理:<SKStoreProductViewControllerDelegate>

- (void)viewDidLoad {
    [super viewDidLoad];


    UIButton *APPStoreStar = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.view addSubview:APPStoreStar];
    APPStoreStar.backgroundColor = [UIColor colorWithRed:0.4272 green:0.4348 blue:0.0112 alpha:0.0];
    
    [APPStoreStar.titleLabel setFont:[UIFont systemFontOfSize:17]];
    [APPStoreStar setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
    [APPStoreStar setTitle:@"去 APP Store 评分" forState:UIControlStateNormal];
    [APPStoreStar setTintColor:[UIColor whiteColor]];
    [APPStoreStar addTarget:self action:@selector(starAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [APPStoreStar mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(ifeedBackInfoLineView.mas_bottom).offset(10);
        make.left.equalTo(weakSelf.view).offset(30);
        make.height.offset(30);
        make.width.offset(145);
        
        
    }];
    
}


###Tip : 注意:你可以在iTunes Connect找到app的唯一识别符,App Store中的每个app都有一个唯一识别符/Apple ID,注意你需要将在参数字典中以字符串的形式传递apple id。

- (void)starAction:(UIButton *)button{

    //初始化Product View Controller
    SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
    //配置View Controller
    [storeProductViewController setDelegate:self];
    [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"这里填写应用 ID "}completionBlock:^(BOOL result, NSError *error){
       if(error)
       {
           NSLog(@"Error %@ with User Info %@.", error, [error userInfo]);
       }
       else
       {
           [self presentViewController:storeProductViewController animated:YES  completion:nil];
       }
   }];
    
    
    
}


-(void) productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
    [self dismissViewControllerAnimated:YES completion:nil];
}



上述代码没能实现,应用内撰写评价评分,可以使用如下的方法实现

NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/idxxxxxx"];
 
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,901评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,803评论 19 139
  • 我到底有多不同? 说起自己的不同,好像很多,别人常常说,我穿衣风格很特别,民族风,很少现代气息。其实对于衣...
    fedad2e5cd07阅读 1,310评论 0 0
  • HYYZKL阅读 1,612评论 0 0
  • 原因说穿了很简单,名家的名作往往浑然一体,一个初学者是很难把文章分解开的。而把文章切不开,就无法进一步地进行深入分...
    夏国斌阅读 4,613评论 0 1

友情链接更多精彩内容