Sachin Prasad
Sachin Prasad

Reputation: 5411

Check if a request came from android App in rails

How can I detect that a request is coming from an Android App and not android browser.

If I use this:

 request.env['HTTP_USER_AGENT'].downcase.match(/android/)

It will also include the android browser.

Upvotes: 0

Views: 1734

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176562

The answer depends on how you coded your Android application. In order to interact with your webapp, the Android app will use an HTTP client. You need to determine how you configured the HTTP client and which user agent you decided to use.

If you are not setting any user agent in the Android application, you may want to release a new version where you pass a specific user agent for the app, in this way you can easily isolate the requests coming from it.

Upvotes: 4

Related Questions