iOS - 获取手机上所有安装的app的bundle id

##获取手机上所有安装的app的bundle id

// 获取手机上所有安装的app的bundle id(iOS11无效) 

- (NSArray*)getOtherAPPInfo{

    if(@available(iOS12.0, *)) {

        ClassLSApplicationWorkspace_Class =NSClassFromString(@"LSApplicationWorkspace");

        NSObject*workspace = [LSApplicationWorkspace_ClassperformSelector:NSSelectorFromString(@"defaultWorkspace")];

        NSArray *plugins = [workspace performSelector:NSSelectorFromString(@"installedPlugins")];

        for(idplugininplugins) {

            idbundle = [pluginperformSelector:NSSelectorFromString(@"containingBundle")];

            if(bundle) {

                NSString *bundleid = [bundle performSelector:NSSelectorFromString(@"bundleIdentifier")];

                NSString *itemName = [bundle performSelector:NSSelectorFromString(@"itemName")];

                if(![bundleidcontainsString:@"com.apple."]) {

                    NSLog(@"*****  %@ <%@>  ****", [bundle performSelector:NSSelectorFromString(@"bundleIdentifier")], [bundle performSelector:NSSelectorFromString(@"itemName")]);

                }

            }

        }

        returnplugins;

    }


    Class lsawsc = objc_getClass("LSApplicationWorkspace");

    NSObject* workspace = [lsawsc performSelector:NSSelectorFromString(@"defaultWorkspace")];

    NSArray *Arr = [workspace performSelector:NSSelectorFromString(@"allApplications")];

    for(NSString* tmpinArr)

    {

        NSString* bundleid =@"";

        NSString* target = [tmpdescription];

        NSArray * arrObj = [target componentsSeparatedByString:@" "];

        if([arrObjcount]>2) {

            bundleid = [arrObjobjectAtIndex:2];

        }

        if(![bundleidcontainsString:@"com.apple."]) {

            NSLog(@"*******  %@  *****",bundleid);

        }

    }

    returnArr;

}

你可能感兴趣的:(iOS - 获取手机上所有安装的app的bundle id)