Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LSApplicationWorkspace not work on iOS 11?

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.

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

like image 717
ovo Avatar asked Jun 28 '17 03:06

ovo


1 Answers

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

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

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;
}
like image 56
inspector_60 Avatar answered Oct 24 '22 07:10

inspector_60