测试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. python网络爬虫从入门到实战开发

    1.简单的抓取网页 from urllib import requestreq=request.Request("http://www.baidu.com")response=re ...

  2. Python魔法:20个让你编程事半功倍的奇淫技巧(建议收藏)

    Python作为一门灵活.充满技巧的语言,有着很多奇技淫巧,今天小编就跟大家分享一下在平时工作中所积累的技巧,这里面既有语法上的技巧,也有库函数的应用,可以帮助大家在平时的工作中提升效率,规避某些错误 ...

  3. 将Abp移植进.NET MAUI项目(三):构建UI层

    ​ 很开心,终于到了创建页面的时候了! 我们需要两个页面 MainPage 主页面 MusicItemPage 条目编辑页面 编写主页面 新建一个MainPageViewModel.cs,作为Main ...

  4. 2.4g无线私有协议透传方案特色梳理

    为什么?  在2.4G这个频段,的确有待你拥挤,有提供高速上网的wifi,有提供短距离数据和云音乐传输的bt,还要各种xx的东西.在wifi和bt无法覆盖的领域,又出来一个2.4G私有协议传输芯片,这 ...

  5. vue入门教程之-组件

    vue入门教程之-组件 欢迎关注博主公众号「java大师」, 专注于分享Java领域干货文章, 关注回复「资源」, 免费领取全网最热的Java架构师学习PDF, 转载请注明出处 https://www ...

  6. JSF之Action 与ActionListener的区别

     事件  检验  参数  事件产生  页面跳转  Action  有 无参数,不传入当前控件,有返回值    当铵钮被单击时产生事件.提交表单   返回页面---根据配置文件跳转  ActionLis ...

  7. 记录:Openlayers6.5 实现轨迹回放

    这篇分享我记录到的一个案例,废话不多说,上代码 import Feature from 'ol/Feature' import LineString from 'ol/geom/LineString' ...

  8. postgresql关于array类型有交集(包含查询数据任意元素,有重叠&&)的一些查询方法以及sqlalchemy语句实现

    表接结构如下 class MachineFixDoc(Base): """ 设备报修单,代理或用户向公司申请报修 """ __tablena ...

  9. Word文档最后一页空白页中换行符无法删除

    Word文档最后一页空白页中换行符无法删除 问题如题: 尝试了delete.backspace.backspace+delete都不行. 找到了这个方法: 选中最后一页的换行符,然后段落--间距--行 ...

  10. ZYNQ7000系列学习

    ZYNQ7000-系列知识学习 一.ZYNQ7000简介 ZYNQ7000是xilinx推出的具有ARM内核的FPGA芯片,可用于常见SOC开发.基于此,通过学习ZYNQ7000的各种设置和开发,可以 ...