1 | import { Platform, NativeModules } from 'react-native';
|
2 | import { DeviceInfoNativeModule } from './privateTypes';
|
3 |
|
4 | let RNDeviceInfo: DeviceInfoNativeModule | undefined = NativeModules.RNDeviceInfo;
|
5 |
|
6 |
|
7 | if (Platform.OS === 'web' || Platform.OS === 'dom') {
|
8 | RNDeviceInfo = require('../web');
|
9 | }
|
10 |
|
11 | if (!RNDeviceInfo) {
|
12 |
|
13 | if (
|
14 | Platform.OS === 'android' ||
|
15 | Platform.OS === 'ios' ||
|
16 | Platform.OS === 'web' ||
|
17 |
|
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 |
|
28 | export default RNDeviceInfo as DeviceInfoNativeModule;
|