expo 热更新方法

首先写个更新响应函数

performUpdate =async()=> {
      // alert("check Update ");
      try {
        const update = await Expo.Updates.checkForUpdateAsync();
        if (update.isAvailable) {
          alert('正在准备更新')
          await Expo.Updates.fetchUpdateAsync();
          // ... notify user of update ...
          alert("更新完成");
            Expo.Updates.reload();
        } else {
          alert('已经是最新版本!')
        }
      } catch (e) {
        console.log('xxxxx:', e)
        // handle or log error
      }
    }

再添加触发方法

 {
                  this.performUpdate();
                }
              }>GeekyAnts

局限性,贴上官网原文

Some native configuration can't be updated by publishing

If you make any of the following changes in app.json, you will need to re-build the binaries for your app for the change to take effect:

  • Increment the Expo SDK Version

  • Change anything under the ios or android keys

  • Change your app splash

  • Change your app icon

  • Change your app name

  • Change your app scheme

  • Change your facebookScheme

  • Change your bundled assets under assetBundlePatterns

On iOS, you can't share your published link

When you publish, any Android user can open your app inside Expo Client immediately.

Due to restrictions imposed by Apple, the best way to share your published app is to build a native binary with Expo's build service. You can use Apple TestFlight to share the app with your testers, and you can submit it to the iTunes Store to share more widely.

你可能感兴趣的:(expo 热更新方法)