SDK API Reference
initNorrix
Initialize the Norrix SDK and optionally start update checking.
Signature
function initNorrix(config: UpdateConfig): NorrixUpdates;Parameters
| Parameter | Type | Description |
|---|---|---|
config | UpdateConfig | Configuration options |
Returns
NorrixUpdates: SDK instance for manual control
Example
import { initNorrix } from '@norrix/client-sdk';
const norrix = initNorrix({
updateUrl: 'https://norrix.net',
checkForUpdatesOnLaunch: true,
installUpdatesAutomatically: true,
});checkUpdates
Convenience function to check for updates using the global instance.
Signature
function checkUpdates(): Promise<UpdateInfo>;Returns
Promise<UpdateInfo>: Update information
Throws
Error if initNorrix hasn’t been called.
NorrixUpdates Class
Main SDK class returned by initNorrix.
checkForUpdates()
Check for available updates from the server.
async checkForUpdates(): Promise<UpdateInfo>Returns: Promise<UpdateInfo>
Example:
const update = await norrix.checkForUpdates();
if (update.updateAvailable) {
console.log('Update available:', update.version);
}downloadUpdate(update)
Download an update package.
async downloadUpdate(update: UpdateInfo): Promise<boolean>Parameters:
| Parameter | Type | Description |
|---|---|---|
update | UpdateInfo | Update info from checkForUpdates() |
Returns: Promise<boolean>. true if download succeeded
Example:
const update = await norrix.checkForUpdates();
if (update.updateAvailable && update.url) {
const success = await norrix.downloadUpdate(update);
}applyUpdate(closeAppNow?)
Apply a downloaded update.
applyUpdate(closeAppNow?: boolean): voidParameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
closeAppNow | boolean | false | Force close app immediately |
Behavior:
- If
promptToRestartAfterInstallistrue: Shows restart dialog - If
closeAppNowistrue: Closes app immediately - Otherwise: Update activates on next natural restart
resetAllOTAs()
Clear all OTA updates and return to the store binary.
resetAllOTAs(): voidBehavior:
- Clears OTA fingerprint from storage
- Clears OTA version/build from storage
- Removes downloaded OTA packages
- Shows restart prompt to user
getCurrentFingerprintHash()
Get the current native binary fingerprint hash.
getCurrentFingerprintHash(): string | undefinedReturns: The fingerprint hash, or undefined if not found
Notes:
- Returns cached value if previously read
- Reads from
assets/norrix.fingerprint.json - Caches result to ensure consistency across OTA updates
getCurrentConfiguration()
Get the deployment configuration embedded in the native binary.
getCurrentConfiguration(): string | undefinedReturns: The configuration string (e.g., 'prod', 'stg'), or undefined if not found
Notes:
- Reads from native resources (Info.plist on iOS, BuildConfig on Android)
- Used to ensure OTA updates match the binary’s deployment target
- Prevents staging updates from being applied to production apps (and vice versa)
closeAppNow()
Utility to immediately close the app.
closeAppNow(): voidPlatform behavior:
- iOS: Calls
exit(0) - Android: Calls
java.lang.System.exit(0)
Warning: Only use after user confirmation.
UpdateConfig Interface
Configuration options for initNorrix.
interface UpdateConfig {
updateUrl: string;
checkForUpdatesOnLaunch?: boolean;
installUpdatesAutomatically?: boolean;
allowStoreUpdateOverride?: boolean;
promptToRestartAfterInstall?: boolean;
statusCallback?: (status: SyncStatus, data?: UpdateInfo) => void;
downloadProgressCallback?: (progress: number) => void;
}| Property | Type | Required | Default | Description |
|---|---|---|---|---|
updateUrl | string | Yes | - | Base URL for OTA server |
checkForUpdatesOnLaunch | boolean | No | false | Auto-check on init |
installUpdatesAutomatically | boolean | No | false | Auto-install updates |
allowStoreUpdateOverride | boolean | No | false | Apply OTA when store update needed |
promptToRestartAfterInstall | boolean | No | false | Show restart dialog |
statusCallback | function | No | - | Status change callback |
downloadProgressCallback | function | No | - | Download progress (0-100) |
UpdateInfo Interface
Information about an available update.
interface UpdateInfo {
updateAvailable: boolean;
platform?: string;
version?: string;
buildNumber?: string;
releaseNotes?: string;
url?: string;
expiresAt?: string;
timestamp?: Date;
message?: any;
requiresStoreUpdate?: boolean;
compatibilityReason?: string;
}| Property | Type | Description |
|---|---|---|
updateAvailable | boolean | Whether an update is available |
platform | string | Platform (ios/android) |
version | string | Update version |
buildNumber | string | Update build number |
releaseNotes | string | Release notes |
url | string | Signed download URL |
expiresAt | string | URL expiration timestamp |
requiresStoreUpdate | boolean | Whether a store update is required |
compatibilityReason | string | Why store update is required |
message | any | Additional message or error |
SyncStatus Enum
Status values for the statusCallback.
enum SyncStatus {
UP_TO_DATE = 'UP_TO_DATE',
UPDATE_INSTALLED = 'UPDATE_INSTALLED',
UPDATE_IGNORED = 'UPDATE_IGNORED',
ERROR = 'ERROR',
SKIPPING_BECAUSE_HMR_ENABLED = 'SKIPPING_BECAUSE_HMR_ENABLED',
IN_PROGRESS = 'IN_PROGRESS',
CHECKING_FOR_UPDATE = 'CHECKING_FOR_UPDATE',
AWAITING_USER_ACTION = 'AWAITING_USER_ACTION',
DOWNLOADING_PACKAGE = 'DOWNLOADING_PACKAGE',
INSTALLING_UPDATE = 'INSTALLING_UPDATE',
}See Sync Status Reference for detailed documentation.
Exports
The SDK exports:
// Main initialization
export { initNorrix, checkUpdates } from './lib/norrix-client-sdk';
// Classes and types
export { NorrixUpdates } from './lib/norrix-updates';
export type { UpdateConfig, UpdateInfo } from './lib/norrix-updates';
// Enum (also available as type)
export { SyncStatus } from './lib/norrix-updates';