开发者

How to identify request from a mobile device

开发者 https://www.devze.com 2023-03-27 09:28 出处:网络
I am making a wcf rest service which will be used from mobile devices. If the request is not from a mobile device, it will not be possible to access the service.

I am making a wcf rest service which will be used from mobile devices. If the request is not from a mobile device, it will not be possible to access the service.

So I need to identify if the reques开发者_如何学Pythont is from android, iphone or windows mobile.

Is there any way that I can identify the request?? I tried to google it but did not get any suitable answer...!!


Unfortunately, User-Agent can be easily faked. Some mobile or desktop browsers allow changing the user-agent string.

This is workable if you are not too concern about it.

If you absolutely must secure the service only accessibly from a mobile device, you would need some kind of authentication / authorization method.

For example, I would develop a mobile application (android or ios) and only allow my service to interact through the application that I developed. The mobile application can then provide an authentication code when establishing contact with my service. Probably the authentication code can be hard-coded inside the mobile app.

However, it's possible that the app can be run from an emulator sdk. You could probably write further checks inside your app to get the hardware details from the mobile device to verify it is actually an mobile hardware. (This i'm not so certain as I haven't really got into it)


I think the only way to identify a mobile device is matching the User-Agent against a list of known mobile UA strings.

Here you have a list: http://www.zytrax.com/tech/web/mobile_ids.html

0

精彩评论

暂无评论...
验证码 换一张
取 消