• iOS开发日记6-跳转appStore评分


    今天博主有一个跳转appStore评分的需求,遇到了一些困难点,在此和大家分享,希望能够共同进步.

    跳转到AppStore让用户能够给我们的应用进行评分,有两种方法,一种是跳出应用,跳转到AppStore,进行评分.另一种是在应用内,内置AppStore进行评分.

    PS:appleID在https://itunesconnect.apple.com中创建应用即可在应用界面获得

    1.跳出应用,跳转到AppStore,进行评分

    如果是7.0以前的系统

    NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=xxxxxx" ];  

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

    如果是7.0以后的系统

    NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/idxxxxxxx"];  

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

     2.在应用内,内置AppStore进行评分

    苹果提供了一个框架StoreKit.framework,导入StoreKit.framework,在需要跳转的控制器里面添加头文件 #import <StoreKit/StoreKit.h>, 实现代理方法:< SKStoreProductViewControllerDelegate >

    //自定义方法

    - (void)loadAppStoreController  

    {  

    // 初始化控制器  

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

    // 设置代理请求为当前控制器本身  

     storeProductViewContorller.delegate = self;  

    [storeProductViewContorller loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:kAppId}  completionBlock:^(BOOL result, NSError *error)   {  

    if(error)  

     {  

    NSLog(@"error %@ with userInfo %@",error,[error userInfo]);  

     }  else  

     {  

    // 模态弹出appstore  

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

      }];  

     }  

      }];  

    }  

    //AppStore取消按钮监听  

    - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController  

    {  

      [self dismissViewControllerAnimated:YES completion:^{  

      }];  

    }  

  • 相关阅读:
    极客技术专题【008期】:CSS3核心技术:选择器
    10670 Work Reduction (贪心 + 被题意坑了- -)y
    hdu 4617 : Weapon
    [poj 2186]Popular Cows[Tarjan强连通分量]
    caldera
    linux内核书籍
    DedeCMS Error:Tag disabled:"php"的解决办法
    China特色创新现状
    麒麟OS剽窃
    国产系统
  • 原文地址:https://www.cnblogs.com/Twisted-Fate/p/4745019.html
Copyright © 2020-2023  润新知