我正在创建一个实现aeroFS https://github.com/redbooth/react-native-auto-updater库的演示反应原生应用 [航空图书馆只不过是每次应用程序打开时都会检查远程服务器的更新,如果有更新,它会下载并要求用户申请更新而不用游戏商店。)
到目前为止,该应用程序可以下载该文件,但在下载后我无法看到应用程序中的任何更改。我确定新活动中未使用新下载的软件包。
在进一步检查库内部时,我在ReactNativeAutoUpdaterActivity类(主类)中找到了以下方法: -
@Override
@Nullable
public String getJSBundleFile() {
updater=ReactNativeAutoUpdater.getInstance(this.getApplicationContext());
updater.setMetadataAssetName(this.getMetadataAssetName());
return updater.getLatestJSCodeLocation();
}
ReactNativeAutoUpdaterActivity从没有这个方法的ReactActivity扩展。我认为这是移动到ReactNativeHost所以我知道这是问题,但现在我应该实现我自己的本机主机类来覆盖该方法,以便一旦新的bundle文件已下载我可以将其应用到应用程序。
答案 0 :(得分:0)
MainApplication.java
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
.
.
.
@Override
public void onCreate(){
super.onCreate();
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
preferences.edit().putString("debug_http_host", "128.xxx.xxx.xxx:1234").apply();
}
使用远程VM时,未公开端口8081,因此:
npm start -- --reset-cache --port=1234
AppDelegate.m(iOS):
jsCodeLocation = [NSURL URLWithString:@"http://128.xxx.xxx.xxx:1234/index.js"];