注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

江志祥的博客

可恶的中国银行,信用卡像病毒啊,取消那么难,,,

 
 
 

日志

 
 

Getting an iPhone UDID from Mobile Safari  

2014-11-26 16:43:12|  分类: 手机_iphone |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

Getting your app into beta tester's hands is a pain. Even with new services like Test Flight the process is confusing and clunky for testers because the user has to login & it's not entirely clear to the user what is going on.

The problem is, you need the person's UDID & they have no idea what it is or how to find it.

Overview of Getting a UDID through 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. Here's an overview:

  1. They click a link to a .mobileconfig XML file on your website
  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
  4. You process the resulting data & show them a "thank you" web page

1) Your .mobileconifg

In this article I'm focused on getting a UDID. You can do many other things, but here is an example configuration for getting the UDID.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5. <key>PayloadContent</key>
  6. <dict>
  7. <key>URL</key>
  8. <string>http://yourwebsite.com/retrieve.php</string>
  9. <key>DeviceAttributes</key>
  10. <array>
  11. <string>UDID</string>
  12. <string>IMEI</string>
  13. <string>ICCID</string>
  14. <string>VERSION</string>
  15. <string>PRODUCT</string>
  16. </array>
  17. </dict>
  18. <key>PayloadOrganization</key>
  19. <string>yourwebsite.com</string>
  20. <key>PayloadDisplayName</key>
  21. <string>Profile Service</string>
  22. <key>PayloadVersion</key>
  23. <integer>1</integer>
  24. <key>PayloadUUID</key>
  25. <string>9CF421B3-9853-4454-BC8A-982CBD3C907C</string>
  26. <key>PayloadIdentifier</key>
  27. <string>com.yourwebsite.profile-service</string>
  28. <key>PayloadDescription</key>
  29. <string>This temporary profile will be used to find and display your current device's UDID.</string>
  30. <key>PayloadType</key>
  31. <string>Profile Service</string>
  32. </dict>
  33. </plist>

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.

Also make sure to register a file handler for .mobileconfig (content type application/x-apple-aspen-config).

2) The User Views Your Provision Profile

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.

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).

Getting an iPhone UDID from Mobile Safari - JiangZX - 江志祥的博客

3) 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 was about the last language I wanted to work in, so I chose to redirect to a page that could handle it better.

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

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.

In my example, that page would receive a 'data' query string parameter containing the xml response from the phone.

  1. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  2. <plist version="1.0">
  3. <dict>
  4. <key>IMEI</key>
  5. <string>12 123456 123456 7</string>
  6. <key>PRODUCT</key>
  7. <string>iPhone4,1</string>
  8. <key>UDID</key>
  9. <string>b59769e6c28b73b1195009d4b21cXXXXXXXXXXXX</string>
  10. <key>VERSION</key>
  11. <string>9B206</string>
  12. </dict>
  13. </plist>

Parsing the Response

Redirecting to a Directory

  评论这张
 
阅读(234)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017