获取LSApplicationWorkspace头文件:
https://github.com/JaviSoto/i...
获取手机中所有装置的app办法

-(void)getAppPlist
{

Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];NSArray*apps = [workspace performSelector:@selector(allApplications)];

// NSArray*appsActivity = [workspace performSelector:@selector(applicationForUserActivityDomainName)];

NSMutableArray*appsIconArr = [NSMutableArray array];NSMutableArray*appsNameArr = [NSMutableArray array];NSLog(@"apps: %@",apps );[apps enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL* stop) {        NSDictionary*boundIconsDictionary = [obj performSelector:@selector(boundIconsDictionary)];        NSString*iconPath = [NSString stringWithFormat:@"%@/%@.png", [[obj performSelector:@selector(resourcesDirectoryURL)]path], [[[boundIconsDictionary objectForKey:@"CFBundlePrimaryIcon"]objectForKey:@"CFBundleIconFiles"]lastObject]];        UIImage*image = [[UIImage alloc]initWithContentsOfFile:iconPath];        id name = [obj performSelector:@selector(localizedName)];        if(image)            {                [appsIconArr addObject:image];                [appsNameArr addObject: name];    }    

// NSLog(@"iconPath = %@", iconPath);

        NSLog(@"name = %@", name);    

// 输入app的属性

    NSLog(@"%@",[self properties_aps:obj]);        NSLog(@"_____________________________________________\n");    NSDictionary * appPropertices = [self properties_aps:obj];    }];//通过applicationIdentifier id。判断是否装置某个APPBOOL isInstall = [workspace performSelector:@selector(applicationIsInstalled:) withObject:@"com.tencent.xin"];if (isInstall) {    //通过bundle id。关上一个APP    [workspace performSelector:@selector(openApplicationWithBundleID:) withObject:@"com.tencent.xin"];}else{    NSLog(@"您还没装置");}

}

//获取app的属性。

  • (NSDictionary *)properties_aps:(id)objc

{

NSMutableDictionary *props = [NSMutableDictionary dictionary];unsigned int outCount, i;objc_property_t *properties = class_copyPropertyList([objc class], &outCount);for (i = 0; i<outCount; i++)    {        objc_property_t property = properties[i];        const char* char_f =property_getName(property);        NSString *propertyName = [NSString stringWithUTF8String:char_f];        id propertyValue = [objc valueForKey:(NSString *)propertyName];        if (propertyValue) [props setObject:propertyValue forKey:propertyName];    }free(properties);return props;

}
通过定时器一直的调度 能够用上面的办法失去 所有正在下载的app

-(void)updateInstallList{

void *lib = dlopen("/System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices", RTLD_LAZY);if (lib){    Class LSApplicationWorkspace = NSClassFromString(@"LSApplicationWorkspace");    id AAURLConfiguration1 = [LSApplicationWorkspace defaultWorkspace];        if (AAURLConfiguration1)    {        id arrApp = [AAURLConfiguration1 allApplications];                for (int i=0; i<[arrApp count]; i++) {                        LSApplicationProxy *LSApplicationProxy = [arrApp objectAtIndex:i];            NSString* bundleId =[LSApplicationProxy applicationIdentifier];            NSString* name = [LSApplicationProxy localizedName];                        NSProgress *progress = (NSProgress *)[LSApplicationProxy installProgress];            InstallingModel *model = [self getInstallModel:bundleId];            //如果是正在下载状态            if (progress)            {                                //曾经检测到的                if (model) {                                        model.progress = [progress localizedDescription];                    model.status  =  [NSString stringWithFormat:@"%@",[[progress userInfo] valueForKey:@"installState"]];                    //第一次检测到的                }else{                    InstallingModel *model = [[InstallingModel alloc] init];                    model.appName = name;                    model.bundleID = bundleId;                    model.progress = [progress localizedDescription];                    model.status  = [NSString stringWithFormat:@"%@",[[progress userInfo] valueForKey:@"installState"]];                                        [_installedAry addObject:model];                }                            }        }    }        if (lib) dlclose(lib);}

}
通过bundle id。判断是否装置和关上app

//通过applicationIdentifier id。判断是否装置某个APP

    BOOL isInstall = [workspace performSelector:@selector(applicationIsInstalled:) withObject:@"com.tencent.xin"];    if (isInstall) {        //通过bundle id。关上一个APP        [workspace performSelector:@selector(openApplicationWithBundleID:) withObject:@"com.tencent.xin"];    }else{        NSLog(@"您还没装置");    }

=