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 {

   // 沒有檢測到新版本

    }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM