Swift -- appStore评分

  • 应用外跳转
UIApplication.shared.openURL(URL(string: "http://itunes.apple.com/cn/app/wechat/id836500024?mt=12")!)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/cn/app/wechat/id836500024?mt=12"]];  
  • 应用内跳转
private func jumpStoreScore() {
   let storeCtrlr = SKStoreProductViewController()
   storeCtrlr.delegate = self
   storeCtrlr.loadProduct(withParameters: [SKStoreProductParameterITunesItemIdentifier: "836500024"]) { [weak self] (isSuccess, error) in
       if isSuccess {
           self?.present(storeCtrlr, animated: true, completion: {
           })
       }else {
           print("error:\(String(describing: error))")
       }
   }
}
func productViewControllerDidFinish(_ viewController: SKStoreProductViewController) {
        dismiss(animated: true) { 
            print("取消 productViewControllerDidFinish")
        }
}
- (void)jumpStoreScore {
    SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];
    storeProductViewContorller.delegate=self;
    [storeProductViewContorller loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"836500024"} completionBlock:^(BOOLresult,NSError*error) {
        if(error) {
            NSLog(@"error %@ with userInfo %@",error,[erroruserInfo]);
        }else{
            [self presentViewController: storeProductViewContorller animated:YES completion: nil];
        }
    }];
}

//AppStore取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
    [self dismissViewControllerAnimated:YES completion:nil];
}

使用应用外的方式可以实现进入AppStore页面
使用应用外跳转就是调不起来,提示:

2017-06-21 16:23:26.787090+0800 xxxx[3308:202712] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/xx/Library/Developer/CoreSimulator/Devices/17CBA861-06CE-40AF-BDDF-88A5A087AF04/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-06-21 16:23:26.788148+0800 xxxx[3308:202712] [MC] Reading from private effective user settings.

好像也没什么权限问题设置的,调不起来也不知道咋回事。。先放着吧,要用的时候在调

参考:iOS 应用跳转到AppStore评分 可内置跳转

你可能感兴趣的:(Swift -- appStore评分)