iOS軟體更新問題

來源:互聯網
上載者:User

標籤:

1.軟體中需要自己在後台伺服器中,設定新的版本號碼。每次登陸軟體從後台拉取資料,用最新版本號碼與目前的版本號進行比較。實現軟體更新。

2.每次登陸軟體從蘋果伺服器拉取資料,用最新版本號碼與目前的版本號進行比較。實現軟體更新。

第一種檢測更新方法的優點是:檢測更新速度快、檢測穩定;缺點是:和app store上的應用版本號碼不同步(app上架需要審核時間,不確定什麼時候成功更新到app store上)。第二種方法檢測更新方法的優點是:檢測版本號碼是即時同步的;缺點是:蘋果網路不穩定,檢測更新延時嚴重,部分APP擷取不到任何參數。

個人喜歡使用第一種,只需要後台伺服器根據app store上架版本號碼手動修改資料就行了,APP版本號碼格式也可以自己定義。

 

代碼如下:

#pragma mark--擷取最新版本

- (void)getNewVerion

{   // 1.取得介面字串

    NSString *getInformation = K_AppInfo;

    // 2.擷取資料

    [UpDataDataService requestData:getInformation withResult:^(id result) {

        NSDictionary *information = [result objectForKey:@"results"][0];

        // 1)擷取最新版本

        NSString *newVersion = [information objectForKey:@"version"];

        // 2)擷取目前的版本

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

        NSString *message = [[NSString alloc] initWithFormat:@"****最新版本:%@,為了不影響您的使用,請儘快更新!",newVersion];

        // 3)判斷最新版本是否大於目前的版本

        if ([newVersion integerValue]>[nowVersion integerValue])

        {   // 4)在非同步呼叫中對UI設定必須回調到主線程

            dispatch_async(dispatch_get_main_queue(), ^{

                UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"提示更新" message:message delegate:self cancelButtonTitle:@"取消更新" otherButtonTitles:@"確定更新", nil];

                [alerView show];

            });

        }

    }];

}

iOS軟體更新問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.