In XCode, in the project navigator, select your project.
In XCode, in the project navigator, select your project.
- Add the `libRNDeviceInfo.a` from the _deviceinfo_ project to your project's _Build Phases ➜ Link Binary With Libraries_
- Click `.xcodeproj` file you added before in the project navigator and go the _Build Settings_ tab. Make sure _All_ is toggled on (instead of _Basic_).
* Add the `libRNDeviceInfo.a` from the _deviceinfo_ project to your project's _Build Phases ➜ Link Binary With Libraries_
- Look for _Header Search Paths_ and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React`
* Click `.xcodeproj` file you added before in the project navigator and go the _Build Settings_ tab. Make sure _All_ is toggled on (instead of _Basic_).
- Mark both as recursive (should be OK by default).
* Look for _Header Search Paths_ and make sure it contains both `$(SRCROOT)/../react-native/React` and `$(SRCROOT)/../../React`
* Mark both as recursive (should be OK by default).
Run your project (Cmd+R)
Run your project (Cmd+R)
(Thanks to @brysgo for writing the instructions)
(Thanks to @brysgo for writing the instructions)
</details>
</details>
<details>
<details>
<summary>Android</summary>
<summary>Android</summary>
- in `android/app/build.gradle`:
* in `android/app/build.gradle`:
```diff
```diff
dependencies {
dependencies {
...
@@ -86,7 +91,7 @@ dependencies {
...
@@ -86,7 +91,7 @@ dependencies {
}
}
```
```
- in `android/settings.gradle`:
* in `android/settings.gradle`:
```diff
```diff
...
...
...
@@ -97,7 +102,7 @@ include ':app'
...
@@ -97,7 +102,7 @@ include ':app'
#### With React Native 0.29+
#### With React Native 0.29+
- in `MainApplication.java`:
* in `MainApplication.java`:
```diff
```diff
+ import com.learnium.RNDeviceInfo.RNDeviceInfo;
+ import com.learnium.RNDeviceInfo.RNDeviceInfo;
...
@@ -119,7 +124,7 @@ include ':app'
...
@@ -119,7 +124,7 @@ include ':app'
#### With older versions of React Native:
#### With older versions of React Native:
- in `MainActivity.java`:
* in `MainActivity.java`:
```diff
```diff
+ import com.learnium.RNDeviceInfo.RNDeviceInfo;
+ import com.learnium.RNDeviceInfo.RNDeviceInfo;
...
@@ -138,17 +143,18 @@ include ':app'
...
@@ -138,17 +143,18 @@ include ':app'
```
```
(Thanks to @chirag04 for writing the instructions)
(Thanks to @chirag04 for writing the instructions)
</details>
</details>
<details>
<details>
<summary>Windows</summary>
<summary>Windows</summary>
- Open the solution in Visual Studio for your Windows apps
* Open the solution in Visual Studio for your Windows apps
- right click your in the Explorer and click Add > Existing Project...
* right click your in the Explorer and click Add > Existing Project...
- Navigate to `./<app-name>/node_modules/react-native-device-info/windows/RNDeviceInfo` and add `RNDeviceInfo.csproj`
* Navigate to `./<app-name>/node_modules/react-native-device-info/windows/RNDeviceInfo` and add `RNDeviceInfo.csproj`
- this time right click on your React Native Windows app under your solutions directory and click Add > Reference...
* this time right click on your React Native Windows app under your solutions directory and click Add > Reference...
- check the `RNDeviceInfo` you just added and press ok
* check the `RNDeviceInfo` you just added and press ok
- open up `MainPage.cs` for your app and edit the file like so:
* open up `MainPage.cs` for your app and edit the file like so:
```diff
```diff
+ using RNDeviceInfo;
+ using RNDeviceInfo;
...
@@ -164,59 +170,61 @@ include ':app'
...
@@ -164,59 +170,61 @@ include ':app'
```
```
(Thanks to @josephan for writing the instructions)
(Thanks to @josephan for writing the instructions)