简体   繁体   中英

How to get mobile device data from a http request?

I've built a web api that is called via an application (iOS/Android) through HTTP requests. I'm trying to implement a GET request that returns different data based on the device, OS, application version, .. etc. I've been using UserAgent with IOS devices and it's working just fine, it goes like that:

        var uaParser = Parser.GetDefault();

        var clientInfo = uaParser.Parse(Request.Headers.UserAgent.ToString());

Also if I opened the request via browser it also returns the data. Example of the response is: UserAgent: Windows 10 Other Chrome 63.0.3239

The problem is in the Android devices, it doesn't send any data about neither the device nor the OS, and I don't want to hard code the details in the android apps, I believe they are sent somewhere as Crashlytics can show these details for both iOS and Android.

Is there is any possible solution to get this data from the requests itself?

If you really wana do that then you could programically get android device name and its version and send it to your server as a parameter in http request...
To get Device Name

String devName = android.os.Build.MODEL;


To get Version code

String androidOS = Build.VERSION.RELEASE;

Then You Could Easily Send Them To Your Server As A Parameter In Your Request And Store Them To Database etc....
Hope This Helps ! Cheers !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM