iOS 11 获取手机已安装APP列表,获取已安装APP的bundleID

iOS11之前用私有API 可以获取设备已安装的app

+ (void)installedApplications {
    Class lsawsc = objc_getClass("LSApplicationWorkspace");
    NSObject* workspace = [lsawsc performSelector:NSSelectorFromString(@"defaultWorkspace")];
    NSArray *apps = [workspace performSelector:NSSelectorFromString(@"allInstalledApplications")];
    Class LSApplicationProxy_class = objc_getClass("LSApplicationProxy");
    for (int i = 0; i < apps.count; i++) {
        NSObject *temp = apps[i];
        if ([temp isKindOfClass:LSApplicationProxy_class]) {
            NSString *appBundleId = [temp performSelector:NSSelectorFromString(@"applicationIdentifier")];
            NSString *appName = [temp performSelector:NSSelectorFromString(@"localizedName")];
            NSString * type = [temp performSelector:NSSelectorFromString(@"applicationType")];
            NSString * shortVersionString = [temp performSelector:NSSelectorFromString(@"shortVersionString")];
            NSString * containerURL = [[temp performSelector:NSSelectorFromString(@"containerURL")] path];
            NSString * resourcesDirectoryURL = [[temp performSelector:NSSelectorFromString(@"resourcesDirectoryURL")] path];
            NSString * bundleExecutable = [temp performSelector:NSSelectorFromString(@"bundleExecutable")];
            NSLog(@"应用类型: %@", type);
            NSLog(@"BundleId: %@", appBundleId);
            NSLog(@"Name: %@", appName);
            NSLog(@"Version: %@", shortVersionString);
            NSLog(@"沙盒路径: %@", containerURL);
            NSLog(@"App包路径: %@", resourcesDirectoryURL);
            NSLog(@"TargetName: %@", bundleExecutable);
            NSLog(@"=============================================");
        }
    }
}

iOS 11以后就不能直接获取设备已安装的APP了,所以可以采用其他办法,思路如下:

1.先获取常用的APP的bundleID
2.检查bundleID在设备上是否存在.

第一:获取常用的APP的bundleID的几种方式

一 : 解压IPA包

1.把.ipa文件的后缀重命名为.zip, 解压.zip压缩包,会有一个Payload 文件夹. 点开Payload文件夹会有一个.app的文件.
2.右键点击.app文件 -> Show Package content. 将会打开新的文件夹包含很多文件.
3.用Xcode打开文件info.plist,就可以找到bundle id, 类似 com…game

二 : 用Mac自带工具Console

1.用数据线连接手机和Mac.
2.打开Mac 应用Console.
3.在左侧栏Devices中,选择你的设备
4.运行你要查看的APP.
5.在搜索栏里面输入App的名字.
6.你可以看到在process列中找到SpringBoard, Message列中找到 Bootstrapping

三 : 在APP下载链接里查看

1.打开Mac的浏览器,搜索app在App Store中iTunes的链接. 比如:
https://itunes.apple.com/us/app/microsoft-outlook/id951937596?mt=8.
2.拷贝数字在URL中id的后面, 比如951937596.
3.打开浏览器
https://itunes.apple.com/lookup?id=<Number copied in step 2>.
比如,
https://itunes.apple.com/lookup?id=951937596.
4.当提示下载text file文本文件, 保存文件. 默认名字是1.txt.
5.打开1.txt文件,搜索bundleId. 比如:
“bundleId”:“com.microsoft.Office.Outlook”

txt文件

四 : idevice 命令查找
1.首先安装brew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
安装brew

2.安装ideviceinstaller

brew install ideviceinstaller
安装ideviceinstaller

3.连接手机,执行以下命令

idevice_id -l
ideviceinstaller -l

第二:检查bundleID是否在设备存在

可以让专门运营的同事查找bundleID,然后上传后端,然后每次启动循环查询,存在就可以存下

- (BOOL)isInstalled:(NSString *)bundleId {
    NSBundle *container = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/MobileContainerManager.framework"];
    if ([container load]) {
        Class appContainer = NSClassFromString(@"MCMAppContainer");
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
        id container = [appContainer performSelector:@selector(containerWithIdentifier:error:) withObject:bundleId withObject:nil];
#pragma clang diagnostic pop
        NSLog(@"%@", [container performSelector:@selector(identifier)]);
        if (container) {
            return YES;
        } else {
            return NO;
        }
    }
    return NO;
}
本人常用APP列表
com.tencent.mqq, "8.4.17.638", "QQ"
com.quliao.swiftDemo, "1", "swiftDemo"
com.jihc.UICollectionViewDemo, "1", "UICollectionViewDemo"
com.nsmetro.shengjingtong, "2020102901", "盛京通"
com.apple.AppStoreConnect, "994", "Connect"
com.wemomo.momoappdemo1, "8.30.2.12", "MOMO陌陌"
com.tencent.smoba, "0013", "王者荣耀"
cn.10086.app, "26", "中国移动"
com.burbn.instagram, "260712851", "Instagram"
com.maxin.MeiTuanWaiMai, "1", "MeiTuanWaiMai"
com.changba.ktv, "10.4.0", "唱吧"
com.qiyi.iphone, "20201126192700", "爱奇艺"
com.mytest.launchtest, "1", "ZYGLaunchIntroductionDemo"
ck.com.CKMeiTuanShopViewyp, "1", "CKMeiTuanShopView"
com.itcast.boxuegu, "4.14.5.0", "博学谷"
com.yaymedialabs.putong, "4.4.0.0", "探探"
com.innovation.driftbottle, "0", "遇见漂流瓶"
com.gx.DragPhotoDemo, "1", "DragPhotoDemo"
com.slp.quarrelno1, "4", "麻豆视频"
com.ss.iphone.ugc.Aweme, "138014", "抖音"
com.tencent.QQKSong, "666", "全民K歌"
CYL.CYLTabBarController, "1", "CYLTabBarController"
D-Code.CustomTabbarViewController, "1", "CustomTabbarViewController"
com.ucweb.iphone.lowversion, "13.1.8.1408", "UC浏览器"
com.quliao.Tease, "1", "会撩"
com.apple.TestFlight, "25", "TestFlight"
com.dapengCompany.DPEduProject, "3.0", "大鹏教育"
cn.gov.tax.its, "20201122212754", "个人所得税"
com.liguangming.Shadowrocket, "939", "Shadowrocket"
com.alipay.iphoneclient, "10.2.8.6010", "支付宝"
com.chinaunicom.mobilebusiness, "207", "手机营业厅"
com.liutao.rider, "20201110", "柳淘骑手端"
com.twototwo.massage, "81", "按个摩"
ck.com.CKMeiTuanShopView, "1", "CKMeiTuanShopView"
com.tencent.xin, "7.0.18.32", "微信"
cn.xiaochuankeji.tieba, "20201130.171000", "最右"
com.tencent.QQMusic, "20020", "QQ音乐"
tanzhenios2019.TZImagePickerController.www, "1", "TZImagePickerController"
com.liutao.business, "1", "柳淘商家端"
com.youku.YouKu, "2014146520", "优酷"
rn.notes.best, "11122019", "爱思极速版"
com.netease.cloudmusic, "1826", "网易云音乐"
com.liutao.user, "1", "柳淘"
com.soulapp.cn, "26888", "SOUL"
cn.ishengsheng.xingjiabi, "2020.1207.23", "他趣"
com.huobanlvxing.www, "95", "伙伴旅行助手"
com.quliao.getBundleId, "1", "getBundleId"
com.weiyingvideo.videoline, "1.2", "抖丽实拍"
com.meitu.myxj, "22950", "美颜相机"
com.baidu.netdisk, "11.3.1.2", "百度网盘"
com.tencent.smobagamehelper, "46140220120301", "王者营地"
WZF.ZFShoppingCart, "1", "ZFShoppingCart"
Jimmywu.JimmyLayout, "1", "JimmyLayout"
developer.apple.wwdc-Release, "831.2.7", "Developer"
limap.StretchTableView, "1", "StretchTableView"
com.baidu.map, "15.2.5.1", "百度地图"
com.tencent.live4iphone, "25342", "腾讯视频"
appledeiMac:~ apple$ idevice_id -l
00008020-00150C8911B8003A
appledeiMac:~ apple$ ideviceinstaller -l
CFBundleIdentifier, CFBundleVersion, CFBundleDisplayName
com.bwton.TJMetro, "1.1", "天津地铁"
com.meitu.mtxx, "28450", "美图秀秀"
com.aliyun.wstudio.amc.AliyunMobileApp, "11161142", "阿里云"
com.tencent.ioshlddz, "7.072.001", "欢乐斗地主"
com.ss.iphone.article.Video, "5.2.6.13", "西瓜视频"
com.cib.cibmb, "3", "兴业银行"
com.bocforms.MobileLife, "5", "缤纷生活"
com.cmbchina.MPBBank, "9003", "招商银行"
com.sym.vjietu2, "380", "微截图2"
com.tongcheng.iphone, "10.0.8.5", "同程旅行"
com.unionpay.chsp, "933", "云闪付"
com.szzc.szzc, "18", "神州租车"
com.jd.jinrong, "618", "京东金融"
com.xiaomi.mihome, "5.5.2.102", "米家"
com.sina.weibo, "49890", "微博"
com.ruubypay.yitongxing, "4.5.0.51", "亿通行"
cn.10086.app, "26", "中国移动"
com.hpbr.bosszhipin, "1606877547", "BOSS直聘"
com.wuba.zhuanzhuan, "100", "转转"
com.cebbank.xyk, "5.1.2.1", "阳光惠生活"
com.iBoxPay.CashBox, "5.0.6.202010211630", "钱盒商户通"
com.caocao.customer, "402", "曹操出行"
com.ccb.ccbDemo, "20201201", "中国建设银行"
com.qiyi.iphone, "20201126192700", "爱奇艺"
com.cjboomMinesweeper.www, "87", "MinesweeperX"
com.apple.TestFlight, "25", "TestFlight"
com.netease.mailmaster, "1689", "网易邮箱大师"
com.nsmetro.shengjingtong, "2020102901", "盛京通"
tv.douyu.live, "635", "斗鱼"
com.meituan.imeituan, "74739", "美团"
com.360buy.jdmobile, "9.3.0", "京东"
com.dapengCompany.DPEduProject, "3.0", "大鹏教育"
com.yueyou.cyreader, "4020008", "七猫小说"
cn.gov.tax.its, "20201122212754", "个人所得税"
com.chinaunicom.mobilebusiness, "12.0", "手机营业厅"
com.xunmeng.pinduoduo, "2011300014", "拼多多"
com.baidu.map, "15.2.5.1", "百度地图"
com.icbc.elife, "1.1.0", "工银e生活"
com.lemon.lv, "4.5.1.01", "剪映"
com.csair.MBP, "202011130011", "南方航空"
com.taobao.taobao4iphone, "20018153", "手机淘宝"
com.huikaiyundian.www, "2", "汇开优店"
com.tencent.ww, "55131", "企业微信"
com.huolala.user, "3", "货拉拉"
com.rgbim.friendsim, "2019091106", "友群"
com.boc.BOCMBCI, "3.0.6", "中国银行"
com.neusoft.gov.syzhyb, "1", "沈阳智慧医保"
com.bytedance.ee.lark, "437", "飞书"
com.apple.AppStoreConnect, "994", "Connect"
com.wondertek.hecmccmobile, "5.8.7.8", "咪咕视频"
com.xiachufang.lanfan, "119", "懒饭"
net.csdn.EducationVideo, "2020.12011723", "程序员学院"
com.tencent.qqmail, "6.1.1.20", "QQ邮箱"
com.quark.browser, "4.5.3.1108", "夸克"
com.zhihu.ios, "2918", "知乎"
com.youku.YouKu, "2014146520", "优酷"
com.ifmoc.DouKouYueDu, "1.16.1.0", "饭团追书"
com.meituan.banma.crowdsource, "712", "美团众包"
com.blueberry.Gmu, "2", "积目"
com.burbn.instagram, "257196069", "Instagram"
com.kugou.kugou1002, "10.3.6.12", "酷狗音乐"
com.jianshu.Hugo, "2011141224", "简书"
com.tencent.microvision, "773", "微视"
rn.notes.best, "11122019", "爱思极速版"
com.hrtpayment.JiSuAppstore, "7", "会员宝秒到版"
com.taobao.travel, "9.6.5.105", "飞猪旅行"
com.tencent.smobagamehelper, "46140220120301", "王者营地"
com.tencent.live4iphone, "25342", "腾讯视频"
com.taofang.iphone, "42742228", "58同城"
com.taobao.fleamarket, "1125994", "闲鱼"
com.netease.cloudmusic, "1898", "网易云音乐"
com.tencent.QQKSong, "666", "全民K歌"
com.tencent.mqq, "8.4.17.638", "QQ"
com.apple.clips, "4990", "可立拍"
com.gdb.mobilegdb, "6.0.0.6", "广发银行"
cn.com.zhaopin.zhilianzhaopin, "7.9.70.5", "智联招聘"
com.BetterJ.www, "436", "蚂蚁加速器"
com.ucweb.iphone.lowversion, "13.1.8.1408", "UC浏览器"
com.rrds.rrdianshi, "41712", "人人视频"
com.BankOfShangHai.1.0, "6.2.1", "上海银行"
com.light.beauty, "3.1.8.16", "轻颜相机"
CtClient, "1", "电信营业厅"
me.ele.ios.eleme, "14127542", "饿了么"
com.liulishuo.engzo2, "12811", "流利说·英语"
com.meanssoft.sygjj, "1", "沈阳公积金"
com.cmbchina.cmblife, "11507", "掌上生活"
cn.missfresh.application, "9.8.98.4", "每日优鲜"
cn.w3cschool.ios, "0.4.1", "编程狮"
com.tmri.12123, "365", "交管12123"
com.cebbank.ebank, "7.1.41", "光大银行"
com.ss.iphone.ugc.Aweme, "138014", "抖音"
com.liutao.user, "1", "柳淘"
com.tplink.cloudrouter, "40314", "TP-LINK"
com.youdianguanjia.www, "1", "汇开优店管家"
com.apple.iMovie, "4990", "iMovie 剪辑"
com.liutao.business, "1", "柳淘商家端"
com.yytingting.iting, "1012", "懒人听书"
com.gemd.iting, "930", "喜马拉雅"
com.Foxtravel.assistant, "7", "Fox Travel Assistant"
com.Mango.MangoOnline, "5.12.3.0", "芒果在线"
com.QianHaiLDY.zuche, "1", "联动云租车"
com.alipay.iphoneclient, "10.2.8.6010", "支付宝"
com.innovation.driftbottle, "0", "遇见漂流瓶"
com.seblong.app.IDream, "20.11.26", "蜗牛睡眠"
cn.com.bmac.iosapp, "4.0.0.1", "北京一卡通"
com.WisdomTheTram.MuSen, "02", "智慧电车"
cn.12306.rails12306, "1", "铁路12306"
com.tencent.smoba, "0013", "王者荣耀"
youdao.trans, "1", "有道翻译官"
com.xiaomi.youpin, "4.6.1.2", "小米有品"
com.douban.frodo, "06480001", "豆瓣"
com.cmbc.mobilePhone, "12", "民生信用卡"
com.black.unique, "2020112401", "全球购骑士特权"
com.alibaba.wireless, "14158577", "阿里巴巴"
developer.apple.wwdc-Release, "831.2.7", "Developer"
com.baidu.netdisk, "11.3.1.2", "百度网盘"
com.kingsoft.www.office.wpsoffice, "11.2.089747", "WPS Office"
com.liutao.rider, "20201110", "柳淘骑手端"
com.ccbfintech.gasp.liaoningprovince, "1", "辽事通"
com.xiaojukeji.didi, "6.0.20.912030001", "滴滴出行"
com.tencent.xin, "7.0.18.32", "微信"
cn.ishengsheng.plus, "2020.1202.14", "他趣Plus"
com.citicbank.creditspace, "7.1.0.2", "动卡空间"
com.cutt.app586432, "28958", "通辽团"
me.ele.ios.LPDCrowdsourceAppStore, "7401", "蜂鸟众包"
com.tencent.cmocmna, "97", "腾讯手游加速器"
com.taobao.tmall, "14127776", "手机天猫"
daojiasuyun58, "5.10.0.0", "快狗打" 
com.apple.store.Jolly, "5.9.0.570", "Apple Store"
com.tencent.mqqsecure, "2900", "腾讯手机管家"
com.yinxiang.iPhone, "373820", "印象笔记"
com.cgb.creditcard.iphone, "11171401", "发现精彩"
com.xiachufang.recipe, "330", "下厨房"
io.fmc.fenmiaoCompany, "1", "Openinstall"
com.soulapp.cn, "26888", "SOUL"
com.cib.xyk, "3", "好兴动"
com.gotokeep.keep, "26332", "Keep"

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,588评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,456评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,146评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,387评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,481评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,510评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,522评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,296评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,745评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,039评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,202评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,901评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,538评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,165评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,415评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,081评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,085评论 2 352

推荐阅读更多精彩内容