在网络应用程序中获取 iphone ID [英] get iphone ID in web app

查看:19
本文介绍了在网络应用程序中获取 iphone ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 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,这个答案来自这篇博文:http://bendytree.com/tips/Getting-an-iPhone-UDID-from-Mobile-Safari

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:

  1. 他们点击了指向您网站上的 .mobileconfig XML 文件的链接
  2. 这会在他们的手机上调出他们的配置设置为他们提供安装"按钮(他们必须按下)
  3. 手机将以加密的 XML 格式将您请求的数据发送到您在.mobileconfig
  4. 您处理结果数据 &向他们展示谢谢"网页

用于检索 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>

您需要填写您自己的 URL 和 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 WARNING:无论出于何种原因,该过程非常特别是关于您的服务器在将用户发送到您预设的 URL 时的响应方式.经过多次尝试,我相信您的接收 url 必须是 .php 文件.这听起来很疯狂,但我是认真的.

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. 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 WARNING:: 我(和其他人)让它工作的唯一方法是重定向到一个目录.我试图重定向到 .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.

在我的示例中,该页面将接收包含来自手机的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆