利用的私有库检测正在安装的app
分为两步:第一,通过placeholderApplications获得所有的正在安装的app的信息
第二,遍历正在安装的app的信息,根据名称获得你想检测的app是否正在安装
一旦使用了私有的接口你的app便不能再上架了
利用私有的库MobileCoreServices检测正在安装的应用
NSMutableArray *app = [NSMutableArray array]; //获得私有的类 Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace"); NSObject *workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)]; //获得所有的正在安装的app,得到的是个数组 NSArray *apps = [workspace performSelector:@selector(placeholderApplications)]; Class LSApplicationProxy_class = objc_getClass("LSApplicationProxy"); //遍历数组,根据app的名称判断哪个app正在安装 for (int i = 0; i < apps.count; i++) { NSObject *temp = apps[i]; if ([temp isKindOfClass:LSApplicationProxy_class]) { NSString *appName = [temp performSelector:NSSelectorFromString(@"localizedName")]; BOOL b = [temp performSelector:NSSelectorFromString(@"isPlaceholder")]; NSLog(@"名称:%@++++%d",appName,b); } }