React Native API
getChannel
The `HotUpdater.getChannel()` function retrieves the current release channel of the app. This is useful when you want to determine which channel updates are being applied from.
By default, if no channel is specified, the app is assigned to the production channel.
For more details about channels, refer to the Channel Guide.
Usage
You can use HotUpdater.getChannel() to dynamically check the release channel in your application logic.
Example
import { HotUpdater, getUpdateSource } from "@hot-updater/react-native";
import { Text, View } from "react-native";
function App() {
const channel = HotUpdater.getChannel();
return (
<View>
<Text>Current Channel: {channel}</Text>
</View>
);
}
export default HotUpdater.wrap({
source: getUpdateSource("<your-update-server-url>", {
updateStrategy: "appVersion", // or "fingerprint"
}),
requestHeaders: {
"Authorization": "Bearer <your-access-token>",
},
})(App);Behavior
- If
releaseChannelis set inhot-updater.config.ts,HotUpdater.getChannel()returns that value. - If no channel is set, the default is
production. - Channels help separate environments such as
dev,staging, andproduction, ensuring that updates are applied correctly. - The initial channel is injected into the native app during the build process based on the
releaseChannelspecified inhot-updater.config.ts. - After the app is built, updates can be deployed to the correct channel using
hot-updater deploy -c <channel>, such ashot-updater deploy -c productionorhot-updater deploy -c dev. - Important: Channel changes require rebuilding the native app to take effect. Simply changing the channel in the configuration file or through deployment commands will not update the channel of an already built app.
- It is crucial to set the correct channel during the initial build, as the app will continue to receive updates only from that specified channel.
Configuration Example (hot-updater.config.ts)
import { defineConfig } from "hot-updater";
import { config } from "dotenv";
config({ path: ".env.hotupdater" });
export default defineConfig({
releaseChannel: "dev", // Specifying the release channel
build: ...,
storage: ...,
database: ...,
});With this configuration, HotUpdater.getChannel() will return "dev". This ensures that all future updates are correctly applied to the dev channel.