import { TurboModuleRegistry } from 'react-native';
* HarmonyOS binding for the RNVersionCheck native module.
*
* RNOH has no legacy NativeModules interop layer, so the four values are read
* through the TurboModule methods declared in `specs/v1/NativeRNVersionCheck.ts`
* instead of the `getConstants()` properties used on Android/iOS. The exported
* `IVersionInfo` semantics are unchanged (`getCountry` async, the rest sync).
*/
function getRNVersionCheck() {
const module = TurboModuleRegistry.get('RNVersionCheck');
if (module == null) {
throw new Error(
'RNVersionCheck TurboModule is not registered. Make sure VersionCheckPackage is linked in the Harmony project.'
);
}
return module;
}
export default {
getCountry: (): Promise<string> => getRNVersionCheck().getCountry(),
getPackageName: (): string => getRNVersionCheck().getPackageName(),
getCurrentBuildNumber: (): number => getRNVersionCheck().getCurrentBuildNumber(),
getCurrentVersion: (): string => getRNVersionCheck().getCurrentVersion(),
};