iOS 11适配:LSApplicationWorkspace无法获取应用安装列表解决方案

来源:互联网 发布:男生身材知乎 编辑:程序博客网 时间:2024/05/23 01:25

iOS11 系统更新后,私有API iOS 11 LSApplicationWorkspace无法获取应用安装列表,导致无法判断某个APP是否已安装。

解决方案:

使用私有库 MobileContainerManager.framework

//iOS 11 判断APP是否安装    if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {        NSBundle *container = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/MobileContainerManager.framework"];        if ([container load]) {            Class appContainer = NSClassFromString(@"MCMAppContainer");            id test = [appContainer performSelector:@selector(containerWithIdentifier:error:) withObject:bundleId withObject:nil];            NSLog(@"%@",test);            if (test) {                return YES;            } else {                return NO;            }        }        return NO;    } else {           //非iOS11通过获取安装列表判断即可    }

备注:
适用“积分墙应用”思路:从服务器获取所有的任务,循环任务数据源,若已安装,则不显示,未安装则显示。

原创粉丝点击