zoukankan      html  css  js  c++  java
  • objective-c IOS应用更新

    本人开发的开发者技术变现资源聚集地,大家支持下,下面是网址

    https://www.baiydu.com

    当前苹果已经禁止了,通过IOS应用直接跳转APP下载链接的方法。但是仍然可以使用另外一种方法直接跳转AppStore。

    这种方法需要增加一个类库StoreKit.framework。 这里使用这功能是为用户提供更新,下面说下我实现这个功能的详细步骤。

    一、增加一个网页到服务器上去,title增加你当前APP的版本号。

          

    、在viewDidLoad里面增加UIWebView加载服务器上增加的网页,并获取当前版本号       

        1:下面是是uiwebview 加载网页的代码

    -(void)viewDidLoad
    {
        [super viewDidLoad];
       BeeUIWebView* getVersionWebView=[[BeeUIWebView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
         getVersionWebView.backgroundColor = [UIColor redColor];
        getVersionWebView.scalesPageToFit =YES;
         NSString *pagePath=[NSString stringWithFormat:@"http://www.jmfww.com/Mobile/iosVersionInfo.html"];
     NSURL    *url =[[NSURL alloc] initWithString: pagePath];
        NSURLRequest *request =  [[NSURLRequest alloc] initWithURL:url];
        getVersionWebView.delegate=self;
        [getVersionWebView loadRequest:request];
        
    }
    View Code

       2:uiwebview代理

    - (void)webViewDidFinishLoad:(UIWebView *)webView
    {
    
        NSString  *value= [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
        NSArray *VersionAndStoreLoadUrlArray= [value componentsSeparatedByString:@","];
        
        NSString *Version=[VersionAndStoreLoadUrlArray objectAtIndex:1];
         NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
            // app名称
          //  NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
            // app版本
            NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
        
            if (![app_Version isEqualToString:Version]) {
             
                showMessage(@"请前往AppStore下载最新版本");
                
                  [self openAppStore:@"932016124"];
                
            }
    }
    View Code

    二、SKStoreProductViewController

    //首先引入SKStoreProductViewController代理SKStoreProductViewControllerDelegate
     //跳转APPSTORE的方法
    -(void)openAppStore:(NSString *)appId{
        SKStoreProductViewController *storeProducVC=
        [[SKStoreProductViewController alloc]init];
        storeProducVC.delegate=self;
        NSDictionary *dict=[NSDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier];
        
        [storeProducVC loadProductWithParameters:dict completionBlock:^(BOOL result, NSError * _Nullable error) {
            if (result) {
                [self  presentViewController:storeProducVC animated:YES completion:nil];
                
            }
        }];
        
    
    }
    
    //SKStoreProductViewController返回代理
    -(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
    {
        [viewController dismissViewControllerAnimated:YES completion:nil];
    }
    View Code
  • 相关阅读:
    单片机爬坑记-02-资源紧缺
    单片机爬坑记-01-内核差异
    操作系统-第6章习题解析
    操作系统-第5章习题解析
    操作系统-第4章习题解析
    操作系统-第3章习题解析
    操作系统-第2章习题解析
    操作系统-第1章习题解析
    BugKu之xxx二手交易市场
    BugKu之备份是个好习惯
  • 原文地址:https://www.cnblogs.com/xiaoliao/p/5429786.html
Copyright © 2011-2022 走看看