根据序列号/唯一 ID 确定设备类型
我们在 iPhone 和 Android(以及即将发布的 Blackberry)上提供移动应用程序。应用程序的功能是相同的 - 我们只是支持几种不同的设备。该应用程序与后端 Web 服务通信以接收数据。
现在,在Web应用程序中,有什么方法可以轻松确定正在连接的设备类型吗?这是我可用的:
设备的序列号(或唯一 ID)(请注意,在 Android 模拟器中,它始终为
000000000000
,而在 iPhone 模拟器中,格式与实际 iPhone 完全不同)在 iPhone 应用程序中,使用
NSMutableUrlRequest / NSURLConnection
建立连接,在 Android 中使用org.apache.http.client.HttpClient
建立连接 p>服务器 Web 应用程序被写成 。
我愿意接受“最佳猜测”近似值:如果 95% 的时间我都是正确的,那么就足以满足我的目的。
我不确定黑莓的任何东西,因为该应用程序还没有准备好。
非常感谢任何想法/帮助。非常感谢。
We have mobile applications on iPhone and Android (and soon to be released Blackberry). The app functionality is the same - we just support several different devices. The app communicates with a back-end web service to receive data.
Now, in the web application, is there any way to easily determine what type of device is connecting to it? Here's what I have available:
serial number (or unique ID) of the device (note that in android simulator it's always
000000000000
and in iphone simulator the format is totally different from actual iphone)in iphone app, connections are made using
NSMutableUrlRequest / NSURLConnection
, in Android connections are made usingorg.apache.http.client.HttpClient
The server web app is written in PHP.
I am willing to settle for a "best-guess" approximation: if I'm right 95% of the time, it's good enough for my purpose.
I'm not sure about any of the blackberry stuff, because that app is still not ready.
Any ideas/help are greatly appreciated. Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看正在访问 HTTP API 的用户代理并嗅探它。这至少在 95% 的情况下都有效。 iOS 应用程序中将包含类似
CFNetwork/xxx.xx.x
的内容。对于 Android / Blackberry,只需尝试一下,看看它们是什么。或者更改您的应用程序以自行设置用户代理,这样您就可以准确地知道您的应用程序的版本等正在访问 API。You could look at the user agent that is hitting the HTTP API and sniff that. That'll work at least 95% of the time. iOS apps will have something like
CFNetwork/xxx.xx.x
in them. For Android / Blackberry just try it out and see what they are. Alternatively change your app to set the user agent yourself so you will know exactly what version of your app, etc is hitting the API.