首页 > 编程知识 正文

查询设备udid描述文件,获取设备udid安全吗

时间:2023-05-06 15:41:47 阅读:201317 作者:4187

通过苹果Safari浏览器获取iOS设备UDID步骤 苹果公司允许开发者通过IOS设备和Web服务器之间的某个操作,来获得IOS设备的UDID(包括其他的一些参数)。这里的一个概述:
1、在你的Web服务器上创建一个.mobileconfig的XML格式的描述文件;
2、用户在所有操作之前必须通过某个点击操作完成.mobileconfig描述文件的安装;
3、服务器需要的数据,比如:UDID,需要在.mobileconfig描述文件中配置好,以及服务器接收数据的URL地址;
4、当用户设备完成数据的手机后,返回提示给客户端用户;
一、配置.mobileconfig 通过配置文件可以获取很多信息,下面是获取UDID、IMEI、ICCID的方法。 <?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://hongbaosuoping.com/udid/receive.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>北京无限点乐科技有限公司</string> <key>PayloadDisplayName</key> <string>查询设备UDID</string> <key>PayloadVersion</key> <integer>1</integer> <key>PayloadUUID</key> <string>3C4DC7D2-E475-3375-489C-0BB8D737A653</string> <key>PayloadIdentifier</key> <string>dianJoy.com.UDID-server</string> <key>PayloadDescription</key> <string>本文件仅用来获取设备标识</string> <key>PayloadType</key> <string>Profile Service</string> </dict></plist> 你需要填写回调数据的URL和PayloadUUID。该PayloadUUID仅仅是随机生成的唯一字符串,用来标识唯一 注意:mobileconfig下载时设置文件内容类型Content Type为:application/x-apple-aspen-config 第二、将mobileconfig部署到服务器上,供应用使用。 <pre name="code" class="php"><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="<span style="color:#ff0000;">Content-Type</span>" <span style="color:#ff0000;">content="text/html</span>;charset=utf-8"/><meta content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"name="viewport"id="viewport"/><title>获取您的UDID</title><body><div id="content">UUDI:<input style="" name="" value="<span style="color:#ff0000;">$udid</span>"/><a class="buttons" rel="external nofollow" rel="external nofollow" href="<span style="color:#ff0000;">udid.mobileconfig</span>" target="_blank">1.点击获取您的UDID</a><a class="buttons" rel="external nofollow" rel="external nofollow" href="<span style="color:#ff0000;">yourapp://?function=valid&uuid=$udid</span>">2.验证ipa</a></div></body></html> 就可以完成将UDID传给你的app的过程(yourapp:) 需要注意的是,我们此时的mobileconfig文件是未签名的文件。我们可以自己设置签名,这里转载别人的方法,点击这里 第三、服务器端接受回馈数据 protectedvoid doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException{ response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); //获取HTTP请求的输入流 InputStream is = request.getInputStream(); //已HTTP请求输入流建立一个BufferedReader对象 BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8")); StringBuilder sb = new StringBuilder(); //读取HTTP请求内容 String buffer = null; while((buffer = br.readLine()) != null){ sb.append(buffer); } String content = sb.toString().substring(sb.toString().indexOf("<?xml"),sb.toString().indexOf("</plist>")+8); //content就是接收到的xml字符串 //进行xml解析即可 String udid = response.setStatus(301); //301之后iOS设备会自动打开safari浏览器 response.setHeader("Location","http://192.168.1.106:8080/udid.jsp?UDID="+udid); //http://192.168.1.106:8080/udid.jsp是用于显示udid的页面,也可以利用之前的下载mobileprofile文件页面} 值得注意的是重定向一定要使用301重定向,有些重定向默认是302重定向,这样就会导致安装失败,设备安装会提示"无效的描述文件
第四、返回的数据样式及处理 <!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>121234561234567</string> <key>PRODUCT</key> <string>iPhone8,1</string> <key>UDID</key> <string>b59769e6c28b73b1195009d4b21cXXXXXXXXXXXX</string> <key>VERSION</key> <string>15B206</string> </dict></plist>



版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。