Reputation: 171
I am implementing API to connect app with server. I have to use deviceId there. As mentioned in here we can use third party library 'react-native-device-info'. But when I am using it I am getting errors as attached screenshots. As per error it's saying to do linking but as I am using react version 0.62, so autolinking is there. So What can be issue? It took too much time to search it but till now I didn't get a proper solution.
Upvotes: 4
Views: 13600
Reputation: 601
You can use react-native-device-info
even in Expo projects. You need to replace Expo Go with a custom build that has react-native-device-info
library baked in.
By default, Expo Go used on Android, iPhone Emulators implies managed workflow (aka only expo-*
modules are being used). However, using any pure react-native-*
libraries falls under bare workflow, so you cannot use Expo Go - the error you see is from Expo Go, not your app.
expo-dev-client
, react-native-device-info
libraries included, and install that on your emulators. This needs to be done once when you add a react-native-*
library.react-native-device-info
.npx expo start --dev-client
and choose your emulator. Your custom build will be launched and you can make live changes as always like in Expo Go.Do check out the section on Development Builds from Expo. Needless to say, I have successfully used react-native-device-info
on my Expo project, because expo-device
cannot provide what I needed.
Upvotes: 5
Reputation: 12210
react-native-device-info library wont work in Expo , since it requires linking of native modules hence the error.It will only work in pure react native apps.
You can check this by expo itself : expo-device
hopeit helps.feel free for doubts
Upvotes: 4