Finding list of installed apps on iphone

后端 未结 7 1657
不知归路
不知归路 2020-11-27 07:03

Is it possible to programatically find out name of all apps installed on my iOS device ? Is there any API available for same ?

Thanks for the help

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 07:37

    You can use runtime objective c to get the list of all installed apps. It will give you an array of LSApplicationProxy objects.

    Following is a code snippet that prints Name of all applications installed in your device.

    Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
    NSObject* workspace = [LSApplicationWorkspace_class performSelector:NSSelectorFromString(@"defaultWorkspace")];
    NSMutableArray *array = [workspace performSelector:NSSelectorFromString(@"allApplications")];
    
    NSMutableArray *mutableArray = [[NSMutableArray alloc] init];
    for (id lsApplicationProxy in array) {
        if(nil != [lsApplicationProxy performSelector:NSSelectorFromString(@"itemName")]){
            [mutableArray addObject:[lsApplicationProxy performSelector:NSSelectorFromString(@"itemName")]];
        }
    }
    NSLog(@"********* Applications List ************* : \n %@",mutableArray);
    

    Don't forget to include .

提交回复
热议问题