Finding list of installed apps on iphone

后端 未结 7 1584
不知归路
不知归路 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:27

    There are ways to do this without a jailbroken device and not get your app rejected.
    1. get a list of currently running processes see this SO answer. You will need to translate from process name to app name.
    2. Check to see if any apps have registered a unique URL scheme with UIApplicationDelegate canOpenURL. There are a few sites cataloging known url schemes, this is the best one.

    If an app is not currently running and does not register a custom url scheme then it will not be detected by these methods. I am interested in hearing a method that will be allowed in the app store that works better than this.

    0 讨论(0)
  • 2020-11-27 07:33

    Yes it is possible to get list of all installed app

    -(void) allInstalledApp
    {    
        NSDictionary *cacheDict;
    
        NSDictionary *user;
    
        static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
    
        NSString *relativeCachePath = [[@"Library" stringByAppendingPathComponent: @"Caches"] stringByAppendingPathComponent: cacheFileName];
    
        NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
    
        cacheDict    = [NSDictionary dictionaryWithContentsOfFile: path];
    
        user = [cacheDict objectForKey: @"User"];
    
        NSDictionary *systemApp=[cacheDict objectForKey:@"System"];
    }   
    

    systemApp Dictionary contains the list of all system related app and user Dictionary contains other app information.

    0 讨论(0)
  • 2020-11-27 07:36

    No, on iOS applications has no access to information of/about other applications due to sandboxed environment.

    0 讨论(0)
  • 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 <objc/runtime.h> .

    0 讨论(0)
  • 2020-11-27 07:42

    You can do it by checking whether an application is installed or not by using canOpenURL method or by checking the background processes and matching them with the name of the app you are interested in.

    0 讨论(0)
  • 2020-11-27 07:44

    try this, it will work even with non-jailbroken devices:

    #include <objc/runtime.h>
    Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
    SEL selector=NSSelectorFromString(@"defaultWorkspace");
    
    NSObject* workspace = [LSApplicationWorkspace_class performSelector:selector];
    
    SEL selectorALL = NSSelectorFromString(@"allApplications");
    
    NSLog(@"apps: %@", [workspace performSelector:selectorALL]);//will give you all **Bundle IDS** of user's all installed apps
    
    0 讨论(0)
提交回复
热议问题