Exemplo n.º 1
0
    /// <summary>
    /// 检测apk版本,确认是否需要强制更新
    /// </summary>
    /// <returns> false:需要强更; true:不需要强更 </returns>
    private static bool CheckAPKVersion()
    {
        string url = ServerInfoConfig.GetApkURL();

        if (string.IsNullOrEmpty(url))
        {
            return(true);
        }

        url += "?sign=" + SDK.GetInstance().GetBundleID() + "&game=" + ServerInfoConfig.GetGame();
        string result = HttpUtil.Get(url);

        if (string.IsNullOrEmpty(result))
        {
            return(true);
        }

        ApkVersionInfo versionInfo = JsonFx.Json.JsonReader.Deserialize <ApkVersionInfo>(result);

        if (null == versionInfo)
        {
            return(true);
        }

        int toVersion  = Util.ParseVersion(versionInfo.version);
        int curVersion = Util.ParseVersion(ServerInfoConfig.GetVersion());

        if (curVersion < toVersion)
        {
            UpdateNoticePanel.Show(versionInfo.notice, () =>
            {
                Application.OpenURL(versionInfo.url);
            });
            return(false);
        }

        return(true);
    }