HotUpdater.reload()

By default, the shouldForceUpdate flag is false, the bundle is downloaded but not applied until the user restarts the app.

Calling HotUpdater.reload() reloads the app. If there is a completed update bundle ready to be applied, it will be applied immediately.

INFO

The shouldForceUpdate flag simply downloads the bundle and calls reload immediately.

Usage

You can use it as shown below, but it is recommended to use it together with the `useHotUpdaterStore().progress value.

Refer to useHotUpdaterStore() for more information.

import { HotUpdater, getUpdateSource } from "@hot-updater/react-native";
import { Button, Text, View } from "react-native";

function App() {
  const handleReload = () => {
    // Immediately reapply if there is a downloaded bundle
    HotUpdater.reload(); 
  }

  return (
    <View>
      <Text>Hello World</Text>

      <Button title="Reload" onPress={handleReload} />
    </View>
  );
}

export default HotUpdater.wrap({
  source: getUpdateSource("<your-update-server-url>", {
    updateStrategy: "fingerprint", // or "appVersion"
  }),
  // If you need to send request headers, you can use the `requestHeaders` option.
  requestHeaders: {
    "Authorization": "Bearer <your-access-token>",
  },
})(App);