问题描述
我想为iphone创建一个网络应用程序,我需要获取设备的ID(而不是用户名/密码)。可以这样做吗?
i want to create a web-app for the iphone and i need to get the ID of the device (instead of username/password). can this be done?
推荐答案
看起来你可以在没有太多工作的情况下获得UDID,这个答案来自这篇博文:
Looks like you can get the UDID without terribly too much work, this answer is from this blog post:http://bendytree.com/tips/Getting-an-iPhone-UDID-from-Mobile-Safari
Apple允许开发人员通过一个人获取一个人的UDID(以及做许多其他事情)手机和网络服务器之间的特殊互动。以下是概述:
Apple allows developers to get a person's UDID (& do many other things) through a special interaction between the phone and your web server. Here's an overview:
- 他们点击您网站上.mobileconfig XML文件的链接
- 这会在他们的手机上提取他们的配置设置。为他们提供
'安装'按钮(他们必须按下) - 手机将您以加密XML请求的数据发送到您在
中设置的URL。 mobileconfig - 您处理结果数据&向他们展示一个谢谢网页
- They click a link to a .mobileconfig XML file on your website
- This pulls up their provisioning settings on their phone & offers them an'Install' button (which they must press)
- The phone sends the data you requested in encrypted XML to the URL you set in your.mobileconfig
- You process the resulting data & show them a "thank you" web page
用于检索UDID的示例.mobileconfig:
Example .mobileconfig for retrieving a UDID:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<dict>
<key>URL</key>
<string>http://yourwebsite.com/retrieve.php</string>
<key>DeviceAttributes</key>
<array>
<string>UDID</string>
<string>IMEI</string>
<string>ICCID</string>
<string>VERSION</string>
<string>PRODUCT</string>
</array>
</dict>
<key>PayloadOrganization</key>
<string>yourwebsite.com</string>
<key>PayloadDisplayName</key>
<string>Profile Service</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>9CF421B3-9853-4454-BC8A-982CBD3C907C</string>
<key>PayloadIdentifier</key>
<string>com.yourwebsite.profile-service</string>
<key>PayloadDescription</key>
<string>This temporary profile will be used to find and display your current device's UDID.</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
您需要填写自己的网址和PayloadUUID。 PayloadUUID不必以特殊方式生成 - 只需确保它对您的应用程序是唯一的。
You'll need to fill in your own URL and PayloadUUID. The PayloadUUID doesn't have to be generated in a special way - just make sure it is unique to your app.
还要确保为.mobileconfig注册文件处理程序(内容类型application / x-apple-aspen-config)。
Also make sure to register a file handler for .mobileconfig (content type application/x-apple-aspen-config).
PayloadOrganization和PayloadDescription会在用户看到配置文件时显示。在我的描述中,我说过按安装继续...之类的内容,因为它们可能会在此屏幕上混淆。
PayloadOrganization and PayloadDescription are shown to the user when they see the profile. In my description, I said something like "Press Install to continue..." since they may be confused on this screen.
您无需签署。 mobileconfig,但是如果你没有,那么他们会看到一个没有签名的警告(见下文)。
You don't have to sign your .mobileconfig, but if you don't then they will see a warning that it is not signed (see below).
收到请求的数据
QUIRK警告:无论出于何种原因,该过程非常特别关注服务器在将用户发送到您的预设URL时的响应方式。经过多次尝试,我相信您的接收URL必须是.php文件。这听起来很疯狂,但我很认真。
Receiving the Requested DataQUIRK WARNING: For whatever reason, the process is EXTREMELY particulary about how your server responds when it sends the user to your preset URL. After many tries, I believe that your receiving url MUST be a .php file. This sounds nuts but I'm serious.
PHP是我想要使用的最后一种语言,因此我选择重定向到可以更好地处理它的页面。
PHP was about the last language I wanted to work in, so I chose to redirect to a page that could handle it better.
<?php
$data = file_get_contents('php://input');
header("Location: http://www.mysite.com/Results?data=".rawurlencode($data));
?>
QUIRK警告::我(及其他人)使其工作的唯一方法是重定向到一个目录。我试图重定向到.aspx页面但失败了。如果您没有做到这一点,那么将向用户显示一条模糊的错误消息&他们会被困住。如果您对此有更好的解释,请在下面留下评论。
QUIRK WARNING:: The only way I (& others) have got it working is to redirect to a directory. I've tried to redirect to a .aspx page and it failed. If you do not get this right, then a vague error message will be shown to the user & they will be stuck. If you have a better explaination for this, please leave a comment below.
您重定向到的页面是显示给用户以结束该过程的页面。
The page that you redirect to is the page that is shown to the user to end the process.
在我的例子中,该页面将收到一个'data'查询字符串参数,其中包含来自手机的xml响应。
In my example, that page would receive a 'data' query string parameter containing the xml response from the phone.
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IMEI</key>
<string>12 123456 123456 7</string>
<key>PRODUCT</key>
<string>iPhone4,1</string>
<key>UDID</key>
<string>b59769e6c28b73b1195009d4b21cXXXXXXXXXXXX</string>
<key>VERSION</key>
<string>9B206</string>
</dict>
</plist>
这篇关于在网络应用中获取iphone ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!