uniapp

uniapp-app检查版本更新

uniapp开发app检查版本更新,可在每次打开app检查更新(也就是App的onLaunch生命周期里)进行检查更新。

若有更新:模态框提示用户“是否选择更新”;选择是则选择浏览器,打开更新下载app的url,进行下载更新。

示例代码:

onLaunch: function() {
  console.log('App Launch')
  // #ifdef APP-PLUS
  // 真机运行不需要检查更新,真机运行时appid固定为'HBuilder'
  if (plus.runtime.appid !== 'HBuilder') {
    uni.request({
      url: '检查更新的服务器地址',
      data: {
        appid: plus.runtime.appid,
        version: plus.runtime.version,
        imei: plus.device.imei
      },
      success: (res) => {
        // 根据实际返回结果处理判断
        if (res.statusCode == 200 && res.data.isUpdate) {
          // 提醒用户更新
          uni.showModal({
            title: '更新提示',
            content: res.data.note ? res.data.note : '是否选择更新',
            success: (ee) => {
              if (ee.confirm) {
                plus.runtime.openURL(res.data.url);
              }
            }
          })
        }
      }
    })
  }
  // #endif
},

62条评论

  • John Deere Z535M Review

    John Deere Z535M Review is on its quality. John Deere z535m Manual is easily understood by any consumer. John Deere Z535M Accessories are available. John Deere Z535M is making some serious money with the ZNYSE brand. This company is known for its quality lawn mower parts and accessories. These are sold in many different locations all over the world, but they are best found online. The company has several models that range from the smallest gas-powered lawn mower to the largest, which is the zero turn riding mower. ZNYSE is a division of the lawn care giant Deere, Inc. Other companies that sell John Deere Z535M products include Toro, Sharp, and others.

Leave a Reply

邮箱地址不会被公开。