UNPKG

1.18 kBPlain TextView Raw
1import { Platform, NativeModules } from 'react-native';
2import { DeviceInfoNativeModule } from './privateTypes';
3
4let RNDeviceInfo: DeviceInfoNativeModule | undefined = NativeModules.RNDeviceInfo;
5
6// @ts-ignore
7if (Platform.OS === 'web' || Platform.OS === 'dom') {
8 RNDeviceInfo = require('../web');
9}
10
11if (!RNDeviceInfo) {
12 // Produce an error if we don't have the native module
13 if (
14 Platform.OS === 'android' ||
15 Platform.OS === 'ios' ||
16 Platform.OS === 'web' ||
17 // @ts-ignore
18 Platform.OS === 'dom'
19 ) {
20 throw new Error(`react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps:
21 • For react-native <= 0.59: Run \`react-native link react-native-device-info\` in the project root.
22 • Rebuild and re-run the app.
23 • If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
24 If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-device-info/react-native-device-info`);
25 }
26}
27
28export default RNDeviceInfo as DeviceInfoNativeModule;