Expo 更新自定义服务器 - 获取但未下载的新包

问题描述 投票:0回答:0

我最近设置了一个自定义的 expo 更新服务器(基于 expo 自己提供的服务器 - https://github.com/expo/custom-expo-updates-server)。我在 expo-updates-server 文件夹中唯一更改的是

.env.local
中的 HOSTNAME 并将其设置为我的域名,因此 url 将如下所示:https://www.test.co/api/manifest

This is the updates and runtimeVersion part inside of my app.json file
(copy paste from the github I linked)

"runtimeVersion": "app",
"updates": {
  "enabled": true,
  "url": "https://test.co/api/manifest",
  "fallbackToCacheTimeout": 30000,
  "codeSigningCertificate": "./code-signing/certificate.pem",
  "codeSigningMetadata": {
    "keyid": "main",
    "alg": "rsa-v1_5-sha256"
  }
},
"assetBundlePatterns": ["**/*"],

如果我这样保留它,/api/manifest 端点会被所有 /api/assets 端点触发,但 ui 不会随着新包而改变。每次我终止并重新启动该应用程序时,端点都会被调用,但什么也没有发生。

我尝试通过添加

"checkAutomatically": "ON_ERROR_RECOVERY"
到 app.json 中的更新来进行调试,以避免在启动时获取应用程序,然后我在我的 App.jsx 中添加了这段代码

useEffect(() => {
  if (!__DEV__ && Platform.OS !== 'web') {
    checkForUpdates();
  }
}, []);

async function checkForUpdates() {
  try {
    const update = await Updates.checkForUpdateAsync();
    if (update.isAvailable) {
      await Updates.fetchUpdateAsync();
      alert(JSON.stringify(fetch));
      await Updates.reloadAsync();
    }
  } catch (err) {
    alert(err);
  }
}

The alert(JSON.stringify(fetch)) is only for test purposes.
I wanted to see what is returned from the function.

使用该代码,每次我终止并重新启动应用程序时,都会出现警报,但什么也没有发生。 从 JSON.stringify(fetch) 返回的内容是:(出于安全原因更改) 黑色大方块包含安全密钥,因此无需显示。

注意:所有网址均可访问,可从浏览器下载。只有 bundle/ios-xxxxxxx.js 文件不可下载,文件内容显示在浏览器上

资产 url 的格式为:https://test.co/api/assets?asset=apps/```runtimeVersion```/```date```/assets/xxxxxxxxxx?runtimeVersion=x&platform=ios

感谢任何可以帮助我解决此问题的人,因为这对我和我的业务都非常重要。该应用程序有时会在客户的设备上崩溃。

react-native expo bundle assets expo-updates
© www.soinside.com 2019 - 2024. All rights reserved.