iOS应用内集成AppStore评分功能

Submitted by lepton on Tue, 11/07/2017 - 17:02

Tags

1...

/**

 * 可评分评论,无次数限制

 */

- (IBAction)appStoreComentBtnAction:(UIButton *)sender {

NSString  * nsStringToOpen = [NSString  stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",@"AppID"];//替换为对应的APPID

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];

}

 

 

2..

/**

 * 只能评分,不能编写评论

 * 有次数限制,一年只能使用三次

 * 使用次数超限后,需要跳转appstore

 */

- (IBAction)systemComentBtnAction:(UIButton *)sender {

if([SKStoreReviewController respondsToSelector:@selector(requestReview)]) {// iOS 10.3 以上支持

    //防止键盘遮挡

    [[UIApplication sharedApplication].keyWindow endEditing:YES];

    [SKStoreReviewController requestReview];

}

 

 

3...

/**

 * 在APP内部加载App Store 展示APP信息,但不能直接跳转到评论编辑页面。

 * 再加载处App Store展示页面后,需要手动点击 评论→ 撰写评论

 */

- (IBAction)webAppStoreBtnAction:(UIButton *)sender {

SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];

storeProductViewContorller.delegate = self;

//加载App Store视图展示

[storeProductViewContorller loadProductWithParameters:

  

 @{SKStoreProductParameterITunesItemIdentifier : @"APPID"} completionBlock:^(BOOL result, NSError *error) {

      

     if(error) {

          

     else {

          

         //模态弹出appstore

          

         [self presentViewController:storeProductViewContorller animated:YES completion:^{

              

         }];

          

     }

      

 }];

}

// 代理方法

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {

[self dismissViewControllerAnimated:YES completion:^{

     

}];

}

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.