Skip to Content
Client SDKAPI Reference

SDK API Reference

initNorrix

Initialize the Norrix SDK and optionally start update checking.

Signature

function initNorrix(config: UpdateConfig): NorrixUpdates;

Parameters

ParameterTypeDescription
configUpdateConfigConfiguration 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:

ParameterTypeDescription
updateUpdateInfoUpdate 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): void

Parameters:

ParameterTypeDefaultDescription
closeAppNowbooleanfalseForce close app immediately

Behavior:

  • If promptToRestartAfterInstall is true: Shows restart dialog
  • If closeAppNow is true: Closes app immediately
  • Otherwise: Update activates on next natural restart

resetAllOTAs()

Clear all OTA updates and return to the store binary.

resetAllOTAs(): void

Behavior:

  1. Clears OTA fingerprint from storage
  2. Clears OTA version/build from storage
  3. Removes downloaded OTA packages
  4. Shows restart prompt to user

getCurrentFingerprintHash()

Get the current native binary fingerprint hash.

getCurrentFingerprintHash(): string | undefined

Returns: 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 | undefined

Returns: 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(): void

Platform 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; }
PropertyTypeRequiredDefaultDescription
updateUrlstringYes-Base URL for OTA server
checkForUpdatesOnLaunchbooleanNofalseAuto-check on init
installUpdatesAutomaticallybooleanNofalseAuto-install updates
allowStoreUpdateOverridebooleanNofalseApply OTA when store update needed
promptToRestartAfterInstallbooleanNofalseShow restart dialog
statusCallbackfunctionNo-Status change callback
downloadProgressCallbackfunctionNo-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; }
PropertyTypeDescription
updateAvailablebooleanWhether an update is available
platformstringPlatform (ios/android)
versionstringUpdate version
buildNumberstringUpdate build number
releaseNotesstringRelease notes
urlstringSigned download URL
expiresAtstringURL expiration timestamp
requiresStoreUpdatebooleanWhether a store update is required
compatibilityReasonstringWhy store update is required
messageanyAdditional 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';