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.

[Android] Inappropriate network user agent

See original GitHub issue

Hi,

Currently making network request will contains the default user agent from okhttp, e.g. okhttp/2.4.0, this’s not the proper way on the iOS which sets the user agent to product_name/bundle_version.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
carobetacommented, Apr 17, 2017

It’s possible to set the user-agent for all network request? Using the same for Android and IOS?

0reactions
matth3wga0commented, Oct 2, 2015

In a nutshell, I tried and failed.

Instead of overriding NetworkingModule, I want to modify MainReactPackage.java, initialize NetworkingModule with the second parameter.

new NetworkingModule(reactContext, defaultUserAgent)

Since I can’t access MainReactPackage.java in the sample app which create with react-native init sample, so I tried to modify the examples UIExplorer inside the master repo, followed with this instruction to install it on my device (5.0.2), but it force stopped immediately once I launched it, the packager is up, and JSMainModule looks fine.

http://localhost:8081/Examples/Movies/MoviesApp.android.bundle?platform=android

Neither UIExplorer nor Movies will force close, but the app created with react-native cli works, 😖

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android HTTP User Agent - Stack Overflow
To complete the accepted answer, if you want the default user agent use System.getProperty("http.agent") client.getParams().setParameter(CoreProtocolPNames.
Read more >
User-Agent - HTTP - MDN Web Docs - Mozilla
The User-Agent request header is a characteristic string that lets servers and network peers identify the application, operating system, ...
Read more >
Make your Android's requests shine with a cool User-Agent
Android needs a standard user-agent, so this is my proposal. ... “A user agent that only specified the network client is NOT a...
Read more >
User-Agent Reduction - Akamai
Chrome is rolling out changes to the browser's User-Agent string that will affect how web servers, applications, and CDNs like Akamai gather ...
Read more >
Understanding Cloudflare User Agent Blocking
User Agent Blocking (UA) rules block specific browser or web application User-Agent request headers. UA rules apply to the entire domain ...
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