question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getUserAgent() and getUserAgentSync() return different results

See original GitHub issue

Bug

When calling getUserAgent() and getUserAgentSync() on an iOS13.4 Simulator, I get the following results:

  • unknown
  • Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

Environment info

System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 327.73 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.12.0 - ~/.nvm/versions/node/v12.12.0/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v12.12.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tv
OS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^16.11.0 => 16.11.0 
    react-native: ^0.62.0 => 0.62.0 
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.5.3

Steps To Reproduce

  1. Simply call both the async and sync methods
  2. Log the results

Describe what you expected to happen:

Receive the same result from both functions.

Reproducible sample code

export default () => {
    useEffect(() => {
        console.log(DeviceInfo.getUserAgentSync());
        DeviceInfo.getUserAgent().then(agent => console.log(agent));
    }, []);

    return (
        <Fragment />
    );
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
emeraldsantocommented, Mar 30, 2020

I checked source code and it seems getUserAgentSync is not available on iOS and therefore defaults to unknown. Closing this as that’s by design.

1reaction
demedoscommented, Aug 5, 2022

there you go 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

getUserAgent() and getUserAgentSync() return different results
When calling getUserAgent() and getUserAgentSync() on an iOS13.4 Simulator, I get the following results: unknown; Mozilla/5.0 (iPhone; CPU ...
Read more >
react-native-device-info | Yarn - Package Manager
Method, Return Type, iOS, Android, Windows, Web ... Only getUserAgent() will return a correct value. All other API methods will return an "empty"...
Read more >
Return the result value with fetch call function from another ...
Since getvals() is returning a Promise, you need to access it's value in a .then() method. Overall, your code should be like this:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found