LSApplicationWorkspace不能在iOS 11上运行吗? [英] Does LSApplicationWorkspace not work on iOS 11?

查看:1248
本文介绍了LSApplicationWorkspace不能在iOS 11上运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个私有的应用程序需要扫描所有应用程序和方案,并通过使用私有API LSApplicationWorkspace defaultWorkspace 和其他功能方法来获取它,例如 privateURLSchemes allInstalledApplications 。这个应用程序运行良好,我可以在iOS 11之前从私有API获得我需要的所有东西,但在这个版本中我只得到一些警告和一个空数组。似乎Apple限制了开发人员无法在iOS 11中私下使用的私有API。

I have an app in private which need to scan all applications and schemes and get it by using private API LSApplicationWorkspace defaultWorkspace with others functional method, such as privateURLSchemes allInstalledApplications. This app works good and I can get all I need from the private API before iOS 11, but in this version I only got some warning and an empty array. It seems Apple limits private API that developer can't use in private in iOS 11.

所以我的问题是在iOS 11中可以采用哪些替代方法来实现我的需求?

So my question is what alternative ways can achieve my need in iOS 11?

推荐答案

更新:此方法在iOS 12上不起作用 - 需要授权

UPDATE: This method does not work on iOS 12 - entitlement required

有一种方法可以查找是否安装了特定的应用程序,它不是所有应用程序的列表,例如 allInstalledApplications ,但它对查询特定的包ID很有用

There is a way to find if a specific application is installed, its not a list of all apps like allInstalledApplications returned but its useful to query for a specific bundle id

以下是一个示例,该方法接收包ID,如果已安装在设备上,则返回true:

Here is an example, the method receives bundle id and return true if it's installed on the device:

- (BOOL)checkIfAppInstalled: (NSString*)bundleID {
    dlopen("/System/Library/PrivateFrameworks/MobileContainerManager.framework/MobileContainerManager",RTLD_NOW);
    Class MBAppManager = NSClassFromString(@"MCMAppDataContainer");
    NSError  * error ;
    id contentApp = [MBAppManager performSelector:@selector(containerWithIdentifier:error:) withObject:bundleID withObject:error];
    return contentApp != nil;
}

这篇关于LSApplicationWorkspace不能在iOS 11上运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆