美文网首页
App Store 相关操作

App Store 相关操作

作者: Ice丶泽 | 来源:发表于2017-03-08 13:32 被阅读0次

以下内容在真机中有效,在模拟器中并不会跳转。appid是在iTunesConnect创建应用时自动生成的ID。

应用描述连接

itms-apps://itunes.apple.com/cn/app/ai-yu/id1077712062?mt=8

跳转到appstore中的app评论页面

 [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=1077712062&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8"]];


跳转到appstore中的app详情页面

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/cn/app/ai-yu/id1077712062?mt=8"]];

版本更新相关操作

/**提示更新*/
- (void)upData {


    //获取手机程序的版本号
    NSString *ver = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"];



    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    [mgr.responseSerializer setAcceptableContentTypes: [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil]];
    //POST必须上传的字段
    NSDictionary *dict = @{@"id":@"Apple ID"};
    [mgr POST:@"https://itunes.apple.com/lookup" parameters:dict success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {



        NSArray *array = responseObject[@"results"];
        if (array.count != 0) {// 先判断返回的数据是否为空
            NSDictionary *dict = array[0];


            //判断版本  [dict[@"version"] floatValue] > [ver floatValue]
            if (dict[@"version"] > ver) {

                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"更新" message:@"更稳定、快速、多彩的功能和体验,立即点击升级!" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil] ;
                alert.delegate = self;
                alert.tag = 222;
                [alert show];
            }
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    }];
}

#pragma mark - AlertViewDelegate
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {

if (alertView.tag == 222) {

        if (buttonIndex == 1) {
            UIApplication *application = [UIApplication sharedApplication];
            [application openURL:[NSURL URLWithString:@"AppStore的下载地址"]];
        }

    }
}

跳转到APPStore进行下载操作

这里需要引入#import <StoreKit/StoreKit.h>头文件,这种方法是在项目中直接打开 APPStore ,不用跳转到 APPStore

- (void)installAnalyze{
    // Initialize Product View Controller
    SKStoreProductViewController *storeProductViewController =
    [[SKStoreProductViewController alloc] init];
    // Configure View Controller
    [storeProductViewController setDelegate:self];
    [storeProductViewController loadProductWithParameters:
     @{SKStoreProductParameterITunesItemIdentifier : @1090863537}
                                          completionBlock:^(BOOL result, NSError *error) {
                                              if (error) {
                                                  NSLog(@"Error %@ with User Info %@.", error, [error userInfo]);
                                              } else {
                                                  // Present Store Product View Controller
                                                   [self presentViewController:storeProductViewController
                                              animated:YES completion:nil];
                                              }
                                          }];
    [self presentViewController:storeProductViewController
                       animated:YES completion:nil];
}

相关文章

网友评论

      本文标题:App Store 相关操作

      本文链接:https://www.haomeiwen.com/subject/zcebgttx.html