日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

iOS 获取appstore 版本

發(fā)布時間:2023/12/19 综合教程 30 生活家
生活随笔 收集整理的這篇文章主要介紹了 iOS 获取appstore 版本 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

項目上線以后一般都涉及到升級。那么iOS 怎樣從appstore獲取到版本

事實上非常easy

    NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?

id=%@",@"987953868"];

當中 最后一串數(shù)字就是當前app的唯一id。 這個id怎樣得到,百度一下 非常easy

然后我們僅僅須要調(diào)用這個 地址。就會返回當前app的一些信息,當中就包含appstore上的版本(前提是項目已經(jīng)上線到appstore)

我們把獲取的過程做了整理 大家直接使用這種方法調(diào)用剛才的地址即可

    // 獲取appStore版本
    NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?

id=%@",@"987953868"]; [self Postpath:url];

#pragma mark -- 獲取數(shù)據(jù)
-(void)Postpath:(NSString *)path
{
    
    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
{
    NSLog(@"receiveData=%@",sender);
    
}

最后打印出來的字典中就包括 版本

receiveData={

status = 1;

version = "1.0.0";

}

好了 ,有什么問題 歡迎加群討論

蘋果開發(fā)群 :414319235 歡迎增加 歡迎討論問題

總結(jié)

以上是生活随笔為你收集整理的iOS 获取appstore 版本的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。