1

I read some post like this, this and some other without response. However seems I found here the solution for IOS device.

I need to reject any http request from any app of any device and process only request from web browser, so the mainly question is:

There is a definitive way to tell if an HTTP request is made from a mobile app or from a web browser?

Thanks

Example: I receive all http request start from mobile/tablet (I'm developing application behind wifi hotspot), so i process request from Facebook App, Whatsup App and browser. I have to reject request from Facebook and Whatsup and process only request from browser. Apps User-agent seems the same of native device browser.

Community
  • 1
  • 1
user2357730
  • 11
  • 1
  • 5

2 Answers2

3

You can do one thing. Set custom user-agent from application side.

You can set custom user-agent in both android and iphone during web-service call request.

For Android

DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "android");

For Iphone

NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] 
                                       initWithURL:[NSURL URLWithString:[yourURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
NSString *userAgent = "iphone";
[urlRequest setValue:userAgent forHTTPHeaderField:@"User-Agent"];

Check in request header if user-agent is "android" or "iphone" is from application and other-wise from browser.

Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
  • Thanks Biraj, but i need to differentiate all app (like facebook app, whatsup etc.) request from browser request. – user2357730 Aug 06 '14 at 14:47
1

you can check for the user-agent in the request header, I remember mobile browsers send a different value for user-agent and desktop browsers a different one. Just debug user-agent header and validate based on the values.

Eric
  • 1,171
  • 2
  • 14
  • 27