AppStore url跳转链接(转)

1、如果是在应用内部跳转到Appstore只需执行如下代码

1、跳转到应用详情

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@”itms-apps://itunes.apple.com/app/id1061880281”]];

其中 @”itms-apps://itunes.apple.com/app/id1061880281”为拼接地址,1061880281为应用在Appstore注册上线时产生的唯一ID

2、跳转到评论

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

2、如果是扫描二维码跳转到appstore

https://itunes.apple.com/app/id1061880281 ,用这个地址生成二维码即可

但是有可能会碰到多国语言问题,你会发现在其他语言下用安卓设备扫描二维码会进入itunes,而默认展示出来的界面确是英文环境,这是你只需要在 https://itunes.apple.com/app/id1061880281 修改为如下:

例如中文:https://itunes.apple.com/cn/app/id1061880281

例如日文:https://itunes.apple.com/jp/app/id1061880281

等等…也就是在com后面加上国家的简写国际字符即可

3、检测新版本升级跳转到AppStore升级

注:这个功能只有写在应用每次启动时检测,如果在设置界面留有检测更新入口,上架时审核会被苹果拒绝,苹果是不允许在AppStore之外的方式升级的

-(void)checkVersion

{

NSString *path = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"1061880281"];

NSURL *url = [NSURL URLWithString:path];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url

                                                       cachePolicy:NSURLRequestReloadIgnoringCacheData

                                                   timeoutInterval:10];



[request setHTTPMethod:@"POST"];



NSOperationQueue *queue = [NSOperationQueue new];



[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response,NSData *data,NSError *error){

    NSMutableDictionary *receiveStatusDic=[[NSMutableDictionary alloc]init];

    if (data) {



        NSDictionary *receiveDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];



        if ([[receiveDic valueForKey:@"resultCount"] intValue]>0) {



            [receiveStatusDic setValue:@"1" forKey:@"status"];

            [receiveStatusDic setValue:[[[receiveDic valueForKey:@"results"] objectAtIndex:0] valueForKey:@"version"]   forKey:@"version"];

        }else{



            [receiveStatusDic setValue:@"-1" forKey:@"status"];

        }

    }else{

        [receiveStatusDic setValue:@"-1" forKey:@"status"];

    }



    [self performSelectorOnMainThread:@selector(receiveData:) withObject:receiveStatusDic waitUntilDone:NO];

}];

}

  • (void)receiveData:(id)sender

{

NSString *serverVersion = [sender objectForKey:@"version"];//版本号



//获取应用当前版本

NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];



// 服务器版本号大于当前版本号

if ([serverVersion compare:currentVersion options:NSNumericSearch] == NSOrderedDescending) {



    NSString *content = [NSString stringWithFormat:@"版本名:%@",serverVersion];



    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"检测到新版本!"message:content delegate:self cancelButtonTitle: @"以后再说" otherButtonTitles:@"立即更新", nil];

    alert.tag = 1;

    [alert show];

} else {

    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"已是最新版本!" message:@"没有找到可更新的版本!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

    [alert show];

}

}

  • (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

if (alertView.tag == 1) {



    if (buttonIndex == 1){

        // 通过获取到的url打开应用在appstore,并跳转到应用下载页面

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1232138855"]];

    }

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值