前提:
- 被检测的app在开发时设置了URLScheme
- 检测的app项目开发时在Plist白名单中添加被检测app的URLSceme
步骤:
- 获取目标app的ipa包
- 从中找到app对应的URLScheme
- 将对应的URLScheme添加到app项目中的info.plist白名单
- 调用方法判断是否安装或打开某个app
解决
一、获取目标app的ipa包
方法:
1、MacBook Appstore应用商店下载Apple Configurator 2并安装。
![](https://img.haomeiwen.com/i2988687/f9cc8dcba43fb706.png)
2、账户登录appleid账号。
3、连接iPhone设备。
![](https://img.haomeiwen.com/i2988687/2b90f7810b383769.png)
4、添加,选择应用,在里面选择要获取ipa包的APP,下载(首先iPhone上要先已安装这个app,不然第一次是通过这个安装,第二次才可以看到ipa包)
![](https://img.haomeiwen.com/i2988687/2dfbfe111f48e232.png)
5、直到看到如下图:
![](https://img.haomeiwen.com/i2988687/acc07d3783eca637.png)
6、这个时候,什么都不要操作,在finder中shift+command+G,打开以下路径,就可以获取到目标APP的ipa包,拷贝出来即可,停止Apple Configurator 2。
~/Library/Group Containers/K36BKF7T3D.group.com.apple.configurator/Library/Caches/Assets/TemporaryItems/MobileApps/
![](https://img.haomeiwen.com/i2988687/cbb31bb73b788c5f.png)
参考文章:iOS获取App ipa包
二、找到对应的URLScheme
1、将ipa包后缀改为.zip,解压,找到包文件,如下如,显示包内容。
![](https://img.haomeiwen.com/i2988687/3ff6b0858a595016.png)
2、找到包内容里的info.plist文件
![](https://img.haomeiwen.com/i2988687/7c543a90f384c639.png)
3、里面找到app设置的URL-scheme
![](https://img.haomeiwen.com/i2988687/797344cf7cb00fb2.png)
三、目标app的URLScheme添加到app中
iOS9之后,需要将URLScheme添加到项目plist白名单中才可以。
![](https://img.haomeiwen.com/i2988687/3e85b05d405fb936.png)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>wechat</string>
<string>weixin</string>
<string>sinaweibo</string>
<string>taobao</string>
<string>xiangyuapp</string>
</array>
四、检查是否安装或直接打开
@IBAction func testInstalledAction(_ sender: Any) {
var app_url_scheme = "weixin" // 微信
app_url_scheme = "taobao" // 淘宝
app_url_scheme = "sinaweibo" // 微博
app_url_scheme = "xiangyuapp" // 相寓
if let url = URL.init(string: "\(app_url_scheme)://") {
let isInstalled = UIApplication.shared.canOpenURL(url)
if isInstalled {
statusLabel.text = "已经安装\(app_url_scheme)"
} else {
statusLabel.text = "没有安装\(app_url_scheme)"
}
UIApplication.shared.open(url, options: [:]) { (finished) in
print("打开...")
}
}
}
判断是否安装其他app:
UIApplication.shared.canOpenURL(url)
打开对应URLScheme的APP:
UIApplication.shared.open(url, options: [:]) { (finished) in
print("打开...")
}
网友评论