简体   繁体   English

在网络应用中获取iphone ID

[英]get iphone ID in web app

i want to create a web-app for the iphone and i need to get the ID of the device (instead of username/password). 我想为iPhone创建一个网络应用程序,我需要获取设备的ID(而不是用户名/密码)。 can this be done? 可以这样做吗?

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 看起来你可以在没有太多工作的情况下获得UDID,这个答案来自这篇博文: http//bendytree.com/tips/Getting-an-iPhone-UDID-from-Mobile-Safari

Apple allows developers to get a person's UDID (& do many other things) through a special interaction between the phone and your web server. Apple允许开发人员通过手机和Web服务器之间的特殊交互来获取一个人的UDID(以及做许多其他事情)。 Here's an overview: 这是一个概述:

  1. They click a link to a .mobileconfig XML file on your website 他们单击您网站上.mobileconfig XML文件的链接
  2. This pulls up their provisioning settings on their phone & offers them an 'Install' button (which they must press) 这会在他们的手机上提取他们的配置设置并为他们提供一个“安装”按钮(他们必须按下)
  3. The phone sends the data you requested in encrypted XML to the URL you set in your .mobileconfig 手机会将您以加密XML请求的数据发送到您在.mobileconfig中设置的URL
  4. You process the resulting data & show them a "thank you" web page 您处理结果数据并向他们显示“谢谢”网页

Example .mobileconfig for retrieving a UDID: 示例.mobileconfig用于检索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>

You'll need to fill in your own URL and PayloadUUID. 您需要填写自己的URL和PayloadUUID。 The PayloadUUID doesn't have to be generated in a special way - just make sure it is unique to your app. PayloadUUID不必以特殊方式生成 - 只需确保它对您的应用程序是唯一的。

Also make sure to register a file handler for .mobileconfig (content type application/x-apple-aspen-config). 还要确保为.mobileconfig注册文件处理程序(内容类型application / x-apple-aspen-config)。

PayloadOrganization and PayloadDescription are shown to the user when they see the profile. 当用户看到配置文件时,会向用户显示PayloadOrganization和PayloadDescription。 In my description, I said something like "Press Install to continue..." since they may be confused on this screen. 在我的描述中,我说过“按安装继续...”之类的内容,因为它们可能会在此屏幕上混淆。

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). 您不必签署.mobileconfig,但如果不签名,则会看到没有签名的警告(见下文)。

未签名的个人资料图片

Receiving the Requested Data QUIRK WARNING: For whatever reason, the process is EXTREMELY particulary about how your server responds when it sends the user to your preset URL. 接收请求的数据 QUIRK警告:无论出于何种原因,该过程都特别关注服务器在将用户发送到您的预设URL时的响应方式。 After many tries, I believe that your receiving url MUST be a .php file. 经过多次尝试,我相信您的接收URL必须是.php文件。 This sounds nuts but I'm serious. 这听起来很疯狂,但我很认真。

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是我想要使用的最后一种语言,因此我选择重定向到可以更好地处理它的页面。

<?php
  $data = file_get_contents('php://input');
  header("Location: http://www.mysite.com/Results?data=".rawurlencode($data));
?>

QUIRK WARNING:: The only way I (& others) have got it working is to redirect to a directory. QUIRK WARNING ::我(及其他人)使其工作的唯一方法是重定向到目录。 I've tried to redirect to a .aspx page and it failed. 我试图重定向到.aspx页面但它失败了。 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. 您重定向到的页面是向用户显示以结束进程的页面。

In my example, that page would receive a 'data' query string parameter containing the xml response from the phone. 在我的示例中,该页面将接收包含来自电话的xml响应的“数据”查询字符串参数。

<!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>

I know it's an old post, but I just want to share an implementation of @powerj1984's solution in php and ready to use that I found here : 我知道这是一个老帖子,但我只想在php中分享@ powerj1984解决方案的实现,并准备使用我在这里找到的:

https://github.com/hunk/get-UDID https://github.com/hunk/get-UDID

It worked for me. 它对我有用。

As I said it's an implementation, refer to @powerj1984's solution for detailed explanation. 正如我所说,这是一个实现,请参阅@ powerj1984的解决方案以获取详细说明。

Hope it will helps someone. 希望它会帮助某人。

Of course not. 当然不是。 That would be a huge privacy hole. 这将是一个巨大的隐私漏洞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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