MCPcopy Create free account
hub / github.com/transistorsoft/react-native-background-geolocation / getNativeBGGeo

Function getNativeBGGeo

src/NativeModule.js:11–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9} from "react-native";
10
11function getNativeBGGeo() {
12 // Prefer TurboModule when the new architecture is enabled.
13
14 if (TurboModuleRegistry && typeof TurboModuleRegistry.get === 'function') {
15 try {
16 const turbo = TurboModuleRegistry.get('RNBackgroundGeolocation');
17 if (turbo) {
18 return turbo;
19 }
20 } catch (e) {
21 // If Turbo lookup fails for any reason, fall through to classic bridge.
22 }
23 }
24
25 // Fallback to classic bridge (old architecture).
26 const legacy = NativeModules && NativeModules.RNBackgroundGeolocation;
27 if (legacy) {
28 return legacy;
29 }
30
31 // If we reach here, the native module is not installed or not linked.
32 throw new Error(
33 '[react-native-background-geolocation] Native module "RNBackgroundGeolocation" not found. ' +
34 'Make sure the library is properly installed and linked for your platform.'
35 );
36}
37
38export const RNBackgroundGeolocation = getNativeBGGeo();
39

Callers 1

NativeModule.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected