Socket
Book a DemoInstallSign in
Socket

react-native-user-agent

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-user-agent

Library that helps you to get mobile application user agent and web view user agent strings.

2.3.1
latest
Source
npmnpm
Version published
Weekly downloads
7.1K
-23.58%
Maintainers
1
Weekly downloads
 
Created
Source

React Native User Agent

Platforms Supported

  • iOS
  • Android

Getting Started Guide

  • Add react-native-user-agent to your dependencies
yarn add react-native-user-agent

or, for npm use

npm install react-native-user-agent --save
  • Link native dependencies

2.1 react-native >= 0.60

Autolinking will take care of the link step, but for iOS, don't forget to run pod install in ios/ folder

If you haven't set up cocoapods yet, please refer to that article

2.2 react-native < 0.60

You have to call link command manualy:

react-native link react-native-user-agent

For manual linking, please refer to:

Usage

import UserAgent from 'react-native-user-agent';

UserAgent.getUserAgent(); //synchronous

UserAgent.getWebViewUserAgent() //asynchronous
    .then(ua => {})
    .catch(e => {})

Examples:

SystemUser-AgentWebView User-Agent
iOSapplication-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
Androidapplication-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

Additionally module returns a set of constants, that are used in user agent string building.

For iOS:

  • systemName
  • systemVersion
  • applicationName
  • applicationVersion
  • buildNumber
  • darwinVersion
  • cfnetworkVersion
  • deviceName deprecated
  • modelName

For Android:

  • systemName
  • systemVersion
  • applicationName
  • applicationVersion
  • buildNumber

Versioning

Breaking History:

  • 2.3.0
    • unification for ios device names
    • fix android gradle script
    • add types definition
  • 2.1.0 - support for tvos
  • 2.0.0 - supports autolinking, native code refactoring, removes UIWebView, getWebViewUserAgent() returns promise
  • 1.0.6 - First release

License

MIT. Copyright (c) 2018 Anton Bebnev.

Keywords

react-native

FAQs

Package last updated on 11 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.