测试iOS app时候,我们可以安装以下4种类型的包 :

AdHoc                 -- 一般为正式环境验证
AppStore             -- 上传AppStore,只有appstore审核通过发布出来后才能安装
Development       -- 一般为测试环境验证
Enterprise            -- 企业证书打包【仅企业账号使用】

其中AdHoc 、Development只有100个设备,  Enterprise不限用户、不限设备,所以没有Enterprise账号的话,只有把设备的udid加入账号后才能重新打包才能安装ipa包。

但获取udid是一件比较麻烦的事情:

网上有很多种方式:https://www.jianshu.com/p/f0ed370a8bc7

对大众来说,最简单是蒲公英网站提供的方式,扫个码,安装个描述文件就可以获取到,但毕竟是第三方的网站,安全是一方面,udid同时也泄露了。

那么怎样搭建一个和蒲公英一样的获取udid的内部网站呢?

第一步:

新建一个mobileconfig.xml文件

<?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>https://axx.thxxxer.cn/get_udid</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>com.cover.the</string>
<key>PayloadDisplayName</key>
<!--文件标题-->
<string>获取UDID</string>
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<!--随机生成的唯一GUID字符串-->
<string>15113571-2012-654y-4511-f0ra10164cec</string>
<key>PayloadIdentifier</key>
<string>com.cover.the</string>
<key>PayloadDescription</key>
<!--文件描述-->
<string>本描述文件仅用来获取设备的UDID,请允许安装!</string>
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>

上面的配置文件里URl是接收ios设备返回udid等值的接口,其他都可以随便填写,也可以直接用这个配置文件。

第二步:

如果mobileconfig.xml文件不签名的话,安装到手机上会显示红色的“未签名”,我们需要对这个配置文件进行一下签名:

两个命令搞定:

/usr/bin/security find-identity -p codesigning -v

这个命令可以查询到mac上可用的证书,做ios开发的或者经常打包ipa的都知道,若自己电脑上没有的话,找ios开发的同学给你一个证书名称就行:

这个双引号之间的名称Apple Development: danxxao dang (qweqw4L=P3)就是我们想要的:

接着执行下面的命令,当然,把mobileconfig.xml文件名修改为udid.mobileconfig:

/usr/bin/security cms -S -N "Apple Development: danxxao dang (qweqw4L=P3)" -i /Users/jakey/Desktop/udid.mobileconfig -o /Users/jakey/Desktop/udid_signed.mobileconfig

执行完后会生成udid_signed.mobileconfig文件,我们可以再改回mobileconfig.xml文件名备用。

第三步:

还记得刚开始mobileconfig.xml文件里的接收接口么,这个地址是需要https的,http是不能访问的,怎么配置https呢?

见前一篇文章:Flask、Tornado、Nginx搭建Https服务

第四步:

搭建flask网站:

1.创建视图:

# -*- coding = utf-8 -*-
# ------------------------------
# @time: 2021/6/29 17:30
# @Author: drew_gg
# @File: get_ios_udid.py
# @Software: cover_app_platform
# ------------------------------ import os
from flask import Blueprint, request, render_template, redirect, url_for, Response
from app.common.common_ios_type import get_ios_type as ios_type ios_udid = Blueprint('ios_udid', "__main__") pl = os.getcwd().split('cover_app_platform')
xml_path = pl[0] + r'cover_app_platform\\app\\static\\xml\\' # 定义全局变量
udid_l = [] @ios_udid.route('/index_udid/', methods=['GET', 'POST'])
def index_udid():
"""
获取udid首页
"""
return render_template('/post/get_udid/udid.html') @ios_udid.route('/show_udid/', methods=['GET', 'POST'])
def show_udid():
"""
展示获取到的udid页面
"""
return render_template('/post/get_udid/show_udid.html', data=udid_l) @ios_udid.route('/down_config/', methods=['GET', 'POST'])
def down_config():
"""
ios设备访问下载配置文件
"""
def file_content(f_p):
with open(f_p, 'rb') as f:
return f.readlines()
file_path = xml_path + 'mobileconfig.xml'
filename = os.path.basename(file_path)
response = Response(file_content(file_path))
# 这里的Content-Type一定要设置为application/x-apple-aspen-config
response.headers['Content-Type'] = 'application/x-apple-aspen-config; chatset=utf-8'
response.headers['Content-Disposition'] = 'attachment;filename="{}"'.format(filename)
return response @ios_udid.route('/get_udid/', methods=['GET', 'POST'])
def get_udid():
"""
获取设备返回的值
"""
global udid_l
b_data = request.data
data_str = str(b_data).split('<?xml')[-1].split('</plist>')[0].split('dict')[1].replace('\\n', '').replace('\\t', '')\
.replace('>', '').replace('<', '').replace('/', '').replace('string', '').split('key')
udid = data_str[4]
product = ios_type.get_phone(data_str[2])
version = data_str[6]
udid_l = [udid, product, version]
# 这里一定要对301进行重定向
return redirect(url_for('ios_udid.show_udid'), code=301)

以上需要注意的地方我都注释了,比如Content-Type和301重定向!

当然,直接获取到的手机型号和真实型号是有个对应关系的,比如我们获取到的是iPhone12,3,实际是iPhone 11 Pro,这个对应关系网上可以查到,开发ios的话,xcode插件里也有:

# -*- coding = utf-8 -*-
# ------------------------------
# @time: 2021/7/1 5:18 PM
# @Author: drew_gg
# @File: get_ios_type.py
# @Software: FM_APP_PKG
# ------------------------------ def get_phone(ios_type):
if ios_type in ["iPhone3,1", "iPhone3,2", "iPhone3,3"]:
return "iPhone 4"
if ios_type in ["iPhone4,1"]:
return "iPhone 4s"
if ios_type in ["iPhone5,1", "iPhone5,2"]:
return "iPhone 5"
if ios_type in ["iPhone5,3", "iPhone5,4"]:
return "iPhone 5c"
if ios_type in ["iPhone6,1", "iPhone6,2"]:
return "iPhone 5s"
if ios_type in ["iPhone7,2"]:
return "iPhone 6"
if ios_type in ["iPhone7,1"]:
return "iPhone 6 Plus"
if ios_type in ["iPhone8,1"]:
return "iPhone 6s"
if ios_type in ["iPhone8,2"]:
return "iPhone 6s Plus"
if ios_type in ["iPhone8,3"]:
return "iPhone SE (GSM+CDMA)"
if ios_type in ["iPhone8,4"]:
return "iPhone SE (GSM)"
if ios_type in ["iPhone9,1"]:
return "iPhone 7 (CDMA)"
if ios_type in ["iPhone9,2"]:
return "iPhone 7 Plus (CDMA)"
if ios_type in ["iPhone9,3"]:
return "iPhone 7 (GSM)"
if ios_type in ["iPhone9,4"]:
return "iPhone 7 Plus (GSM)"
if ios_type in ["iPhone10,1"]:
return "iPhone 8 (CDMA)"
if ios_type in ["iPhone10,2"]:
return "iPhone 8 Plus (CDMA)"
if ios_type in ["iPhone10,3"]:
return "iPhone X (CDMA)"
if ios_type in ["iPhone10,4"]:
return "iPhone 8 (GSM)"
if ios_type in ["iPhone10,5"]:
return "iPhone 8 Plus (GSM)"
if ios_type in ["iPhone10,6"]:
return "iPhone X (GSM)"
if ios_type in ["iPhone11,2"]:
return "iPhone XS"
if ios_type in ["iPhone11,4"]:
return "iPhone XS Max China"
if ios_type in ["iPhone11,6"]:
return "iPhone XS Max"
if ios_type in ["iPhone11,8"]:
return "iPhone XR"
if ios_type in ["iPhone12,1"]:
return "iPhone 11"
if ios_type in ["iPhone12,3"]:
return "iPhone 11 Pro"
if ios_type in ["iPhone12,5"]:
return "iPhone 11 Pro Max"
if ios_type in ["iPhone12,8"]:
return "iPhone SE 2nd Gen"
if ios_type in ["iPhone13,1"]:
return "iPhone 12 mini"
if ios_type in ["iPhone13,2"]:
return "iPhone 12"
if ios_type in ["iPhone13,3"]:
return "iPhone 12 Pro"
if ios_type in ["iPhone13,4"]:
return "iPhone 12 Pro Max"
if ios_type in ["i386", "x86_64"]:
return "Simulator"
else:
return "I do not know !"

2.创建html页面(css文件去掉了,这两个网站随便整都行):

udid.html:

<!DOCTYPE html>
<head>
<title>封面 | 快速获取 iOS 设备的UDID</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="webpage">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
</head>
<body class="tools-box">
<div class="container-fluid wrapper">
<div class="container content inner-content" style="padding-bottom:40px;">
<div class="row">
<div class="col-md-10 col-md-offset-1 col-sm-8 col-sm-offset-2">
<div class="row text-center">
<div class="margin-bottom-30">
<h2 class="font-36 color-333">一步快速获取 iOS 设备的 UDID</h2>
</div>
</div>
<div class="row text-center">
<div class="col-md-12">
<p class="mb-40 color-8c9497 font-16">请使用 <span class="color-green">iPhone或iPad</span>上的<span class="color-green">Safari</span>浏览器或<span class="color-green">相机</span>扫描下面的二维码,即可快速获取 UDID</p>
</div>
<div class="row text-center" id="UDIDQR">
<div class="col-md-8 col-xs-12 col-md-offset-2 mt-40">
<div class="row" style=" ">
<div class="col-md-6 col-xs-12 col-sm-6 mb-40">
<img src="https://pkg/fm/1.1.0/cover.png" style="height:220px" />
</div>
<div class="col-md-6 col-xs-12 col-sm-6 mb-0">
<div id="UDIDQRImg" style="">
<img src="https://pkg/fm/1.2.0/iosudid.png?content=https://apxx.the.cn/down_config" class="udid img-responsive center-block"/>
<p class="mt-5">扫描二维码,获取 UDID</p>
</div>
</div>
</div>
</div>
</div>
</div>
<hr style="border-top:2px solide #e6e6e6;" />
<div class="col-md-10 col-md-offset-1 input-group margin-bottom-20 mt-60">
<p class="font-18 color-333 ">扫码后怎么操作呢</p>
<p class="color-8c9497 mb-35">扫码后会下载一个描述文件,需要安装,步骤如下:<br>
<font color="red">
1. ios手机打开“设置”; <br>
2. 找到“通用”并点击; <br>
3. 找到“描述文件与设备管理”或“设备管理”并点击; <br>
4. 找到“查询设备UDID”并点击; <br>
5. 点击右上角的“安装”按钮即可。<br>
</font>
</p>
<p class="font-18 color-333">什么是UDID?</p>
<p class="color-8c9497 mb-35">UDID 是 iOS 设备的一个唯一识别码,每台 iOS 设备都有一个独一无二的编码,这个编码,我们称之为识别码,也叫做UDID( Unique Device Identifier)。</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

show_udid.html:

<!DOCTYPE html>
<head>
<title>封面 | 快速获取 iOS 设备的UDID</title>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:type" content="webpage">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
</head>
<body class="tools-box">
<div class="container-fluid wrapper">
<div class="container content inner-content">
<div class="row">
<div class="col-md-10 col-md-offset-1 col-sm-8 col-sm-offset-2">
<div class="row text-center" style="margin-left: 0; margin-right: 0;">
<div class="row text-center" id="UDIDQR">
<div class="col-md-8 col-xs-12 col-md-offset-2 mt-40">
<div class="row" style=" ">
<div class="col-md-6 col-xs-12 col-sm-6 mb-40">
<img src="https://p1.0/cover.png" style="height:220px" />
</div>
</div>
</div>
</div>
<h5 class="color-878f92 font-16 mb-15" style="text-align: left;">设备信息UDID:</h5>
<div style="text-align: left;word-break:break-all;background: #f3f3f3;border-radius: 4px;min-height: 40px;height: auto;padding: 8px 10px;border: 1px solid #ddd;" class="tag-box tag-box-v3 mb-25">
<p class="color-333" style="font-size: 14px">{{data[0]}}</p>
</div>
<h5 class="color-878f92 font-16 mb-15" style="text-align: left;">设备型号:</h5>
<div style="text-align: left;word-break:break-all;background: #f3f3f3;border-radius: 4px;min-height: 40px;height: auto;padding: 8px 10px;border: 1px solid #ddd;" class="tag-box tag-box-v3 mb-25">
<p class="color-333" style="font-size: 14px">{{data[1]}}</p>
</div>
<h5 class="color-878f92 font-16 mb-15" style="text-align: left;">版本号:</h5>
<div style="text-align: left;word-break:break-all;background: #f3f3f3;border-radius: 4px;min-height: 40px;height: auto;padding: 8px 10px;border: 1px solid #ddd;" class="tag-box tag-box-v3 mb-25">
<p class="color-333" style="font-size: 14px">{{data[2]}}</p>
</div> </div>
</div>
</body>
</html>

然后app里注册蓝图即可

ok,到此为止,我们就自己搭建完成了flask获取udid网站:

有兴趣搭建遇到问题的,欢迎讨论。

Python Flask获取iOS的UDID的更多相关文章

  1. 【转】iOS设备的UDID是什么?苹果为什么拒绝获取iOS设备UDID的应用?如何替代UDID?

    本文讲诉的主要是为什么苹果2011年8月发布iOS 5后就开始拒绝App获取设备的UDID以及UDID替补方案,特别提醒开发者苹果App Store禁止访问UDID的应用上架(相关推荐:APP被苹果A ...

  2. python flask获取微信用户信息流程

    需要了解的几个url 用户第一次访问时的url,包含以下几个参数 https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID& ...

  3. python flask获取微信用户信息报404,nginx问题

    在学习flask与微信公众号时问题,发现测试自动回复/wechat8008时正常,而测试获取微信用户信息/wechat8008/index时出现404.查询资料后收发是nginx配置问题. 在loca ...

  4. 获取ios设备的udid

    今天get的第二个技能~~~ UDID指的是设备的唯一设备识别符,ipa包未上架之前如果不添加udid是无法安装成功的.那么如何快速获取ios设备的udid呢? 今天get的方法是用蒲公英,网址:ht ...

  5. AFNetworking+Python+Flask+pyOpenSSL构建iOS HTTPS客户端&服务器端

    对于HTTPS我在网上找了一堆资料看了下, 各种协议和证书已经有点晕了 最后我现有的感觉是, 在HTTP服务器上放一个证书, 在原本的HTTP访问之前客户端先检查证书是否正确 如果客户端证书检查正确, ...

  6. Python Flask 实现移动端应用接口(API)

    引言 目前,Web 应用已形成一种趋势:业务逻辑被越来越多地移到客户端,逐渐完善为一种称为富互联网应用(RIA,rich Internet application)的架构.在 RIA 中,服务器的主要 ...

  7. [Python][flask][flask-login]关于flask-login中各种API使用实例

    本篇博文跟上一篇[Python][flask][flask-wtf]关于flask-wtf中API使用实例教程有莫大的关系. 简介:Flask-Login 为 Flask 提供了用户会话管理.它处理了 ...

  8. 使用wfastcgi在IIS上部署Python Flask应用

    本文介绍了如何在Windows上部署Python Flask应用,相关环境如下: 操作系统:windows 7 Python:3.4 WFastCGI: 2.2 应用所用到的包版本如下: Flask= ...

  9. Taffy Web开发,Python Flask实践详解

    1. 前言 最近为Taffy自动化测试框架写了个页面,主要实现了用例管理.执行,测试报告查看管理.发送邮件及配置等功能. 2. 实现细节 页面使用Python Flask +Bootstrap开发,还 ...

  10. 细数Python Flask微信公众号开发中遇到的那些坑

    最近两三个月的时间,断断续续边学边做完成了一个微信公众号页面的开发工作.这是一个快递系统,主要功能有用户管理.寄收件地址管理.用户下单,订单管理,订单查询及一些宣传页面等.本文主要细数下开发过程中遇到 ...

随机推荐

  1. 别名路径跳转 - vscode 插件

    别名路径跳转 - vscode 插件

  2. C++统计代码运行时间

    本来想自己写的,一看github上面都有就不再重复造轮子了.github上的项目如下: StopWatch 纯标准库实现:使用std::chrono::high_resolution_clock,其实 ...

  3. C++容器博客汇总

    文章的原作者为 https://blog.csdn.net/qq_37529913?type=blog C++ STL 容器.迭代器.适配器(深入了解,一文学会) 1.STL容器 2.序列式容器    ...

  4. 简单实用算法——二分查找法(BinarySearch)

    目录 算法概述 适用情况 算法原理 算法实现(C#) 实际应用:用二分查找法找寻边界值 参考文章 算法概述 二分查找(英语:binary search),也叫折半查找(英语:half-interval ...

  5. 在更新数据的时候,显示一个软件源里面没有Release文件

  6. 【算法】C和Python实现快速排序-三数中值划分选择主元(非随机)

    一.快排基础 1.1 快排的流程 将数组A进行快速排序的基本步骤-quick_sort(A): 递归基础情况:如果A中的元素个数是1或0,则返回. 选取主元:取A中的任意一个元素v,作为主元(pivo ...

  7. View事件机制分析

    目录介绍 01.Android中事件分发顺序 1.1 事件分发的对象是谁 1.2 事件分发的本质 1.3 事件在哪些对象间进行传递 1.4 事件分发过程涉及方法 1.5 Android中事件分发顺序 ...

  8. MacOS安装 JDK 及动态切换版本

    MacOS安装 JDK 及动态切换版本 JDK下载  我自己使用的是Mac m2系列.无所谓用的哪一种开源的OPEN JD,按需下载,我下载了8,11,17三个版本. 安装完成后,终端输入 java ...

  9. archlinux xfce 出现[FAILED] Failed to mount /boot, systemctl status boot.mount出现 mount: /boot: unknown filesystem type 'vfat' 滚挂了

    开机显示:[FAILED] Failed to mount /boot 使用命令systemctl status boot.mount后出现 mount: /boot: unknown filesys ...

  10. 算法学习笔记【1】| LCA(最近公共祖先)

    LCA(最近公共祖先) Part 1:逐步上跳 假设u,v是所求的两点,先把深度大的点逐步上移直到深度相同. 然后两者同时上移,直到第一次遇到相同的点为止. 时间复杂度: O(n)<script ...