Skip to content

Commit b5acb6e

Browse files
committed
version 2.0.0
1 parent 71496c3 commit b5acb6e

2 files changed

Lines changed: 42 additions & 44 deletions

File tree

README.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,55 @@
11

2-
# react-native-user-agent
2+
# React Native User Agent
33

4-
## Getting started
4+
## Platforms Supported
55

6-
Install with [npm](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/):
6+
- [x] iOS
7+
- [x] Android
78

8-
npm:
9-
```sh
10-
npm install react-native-user-agent --save
11-
```
9+
## Getting Started Guide
10+
11+
1. Add react-native-user-agent to your dependencies
1212

13-
Yarn:
1413
```sh
1514
yarn add react-native-user-agent
1615
```
1716

18-
### Mostly automatic installation
17+
or, for npm use
1918

20-
`$ react-native link react-native-user-agent`
19+
```sh
20+
npm install react-native-user-agent --save
21+
```
2122

22-
After that, add this to your `Podfile` and run `pod install`
23+
2. Link native dependencies
2324

24-
```
25-
pod 'RNUserAgent', :path => '../node_modules/react-native-user-agent/ios'
26-
```
25+
2.1 **react-native >= 0.60**
2726

28-
### Manual installation
27+
Autolinking will take care of the link step, but for iOS, don't forget to run `pod install` in `ios/` folder
2928

29+
If you haven't set up cocoapods yet, please refer to [that article](https://engineering.brigad.co/demystifying-react-native-modules-linking-ae6c017a6b4a)
3030

31-
#### iOS
31+
2.2 **react-native < 0.60**
3232

33-
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
34-
2. Go to `node_modules``react-native-user-agent` and add `RNUserAgent.xcodeproj`
35-
3. In XCode, in the project navigator, select your project. Add `libRNUserAgent.a` to your project's `Build Phases``Link Binary With Libraries`
36-
4. Run your project (`Cmd+R`)<
33+
You have to call `link` command manualy:
3734

38-
#### Android
35+
```sh
36+
react-native link react-native-user-agent
37+
```
3938

40-
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
41-
- Add `import com.bebnev.RNUserAgentPackage;` to the imports at the top of the file
42-
- Add `new RNUserAgentPackage()` to the list returned by the `getPackages()` method
43-
2. Append the following lines to `android/settings.gradle`:
44-
```
45-
include ':react-native-user-agent'
46-
project(':react-native-user-agent').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-user-agent/android')
47-
```
48-
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
49-
```
50-
compile project(':react-native-user-agent')
51-
```
39+
*For manual linking*, please refer to:
40+
- [that article](https://engineering.brigad.co/demystifying-react-native-modules-linking-964399ec731b) for Android
41+
- [react-native own tutorial](https://facebook.github.io/react-native/docs/linking-libraries-ios) for iOS
5242

5343
## Usage
5444

5545
```javascript
5646
import UserAgent from 'react-native-user-agent';
5747

58-
UserAgent.getUserAgent();
59-
UserAgent.getWebViewUserAgent();
48+
UserAgent.getUserAgent(); //synchronous
49+
50+
UserAgent.getWebViewUserAgent() //asynchronous
51+
.then(ua => {})
52+
.catch(e => {})
6053
```
6154

6255
### Examples:
@@ -66,27 +59,32 @@ UserAgent.getWebViewUserAgent();
6659
| iOS | application-name/1.6.4.176 CFNetwork/897.15 Darwin/17.5.0 (iPhone/6s iOS/11.3) | Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E217 |
6760
| Android | application-name/1.6.7.42 Dalvik/2.1.0 (Linux; U; Android 5.1.1; Android SDK built for x86 Build/LMY48X) | Mozilla/5.0 (Linux; Android 5.1.1; Android SDK built for x86 Build/LMY48X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36 |
6861

69-
### Additionally:
62+
Additionally module returns a set of constants, that are used in user agent string building.
7063

71-
Every version returns some constants that are used in user agent string building.
72-
73-
iOS version returns:
64+
For iOS:
7465
- systemName
7566
- systemVersion
7667
- applicationName
7768
- applicationVersion
78-
- applicationBuildNumber
69+
- buildNumber
7970
- darwinVersion
8071
- cfnetworkVersion
81-
- deviceName
72+
- deviceName **deprecated**
73+
- modelName
8274

83-
Android version returns:
75+
For Android:
8476
- systemName
8577
- systemVersion
8678
- applicatioName
8779
- applicationVersion
88-
- applicationBuildNumber
80+
- buildNumber
81+
82+
## Versioning
83+
84+
**Breaking History:**
8985

86+
- [2.0.0](https://github.com/bebnev/react-native-user-agent/releases/tag/v2.0.0) - supports [autolinking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md), native code refactoring, removes UIWebView, `getWebViewUserAgent()` returns promise
87+
- [1.0.6](https://github.com/bebnev/react-native-user-agent/releases/tag/v1.0.6) - First release
9088

9189
## License
9290

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-user-agent",
3-
"version": "1.0.6",
3+
"version": "2.0.0",
44
"description": "Library that helps you to get mobile application user agent and web view user agent strings.",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)