iOS 跳转到Appstore的链接及二维码

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"]];

注:由于iOS11对应用商店进行了重新设计,使用该链接在iOS11系统上会发现找不到应用。解决办法:判断系统版本,如果系统版本大于iOS11,跳转上1链接即可

 

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

等等...也就是在https://itunes.apple.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) {

       // 有新版本,执行升级操作

    } else {

   // 没有检测到新版本

    }

}

posted @   HEJJY  阅读(18849)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示