1

I'm new to iOS development, i need small information.how to get all install applications in non jail broken device programatically.

i did googling but i got information "its possible only in non-jailbroken device".

please tell me how to we get list. i wrote below code for that

    NSFileManager *manager = [NSFileManager defaultManager];
    NSArray *fileList = [manager directoryContentsAtPath:documentsDirectory];
    for (NSString *s in fileList)
    {
       NSLog(s);
    }

1 Answers1

0

Note : Your Application will be sand-boxed in any Apple Device and you can only use the information inside that sand-boxed environment. You are not allowed to use information of other Application out side your Application Environment in Non-jailbroken Devices. Apple will reject your app if you will try to use that below code for Non-jailbroken Devices. Use this code for jailbroken Devices only.

Sample Code :

-(NSMutableArray *)desktopAppsFromDictionary:(NSDictionary *)dictionary
{
    NSMutableArray *desktopApps = [NSMutableArray array];
    for (NSString *appKey in dictionary)    {
        [desktopApps addObject:appKey];
    }
    return desktopApps;
}

-(void)installedApp
{
    static NSString* const installedAppListPath = @"/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist";
    BOOL isDir = NO;
    if([[NSFileManager defaultManager] fileExistsAtPath: installedAppListPath isDirectory: &isDir] && !isDir) 
    {
        NSMutableDictionary *cacheDict = [NSDictionary dictionaryWithContentsOfFile: installedAppListPath];
        NSDictionary *system = [cacheDict objectForKey: @"System"];
        NSMutableArray *installedApp = [NSMutableArray arrayWithArray:[self desktopAppsFromDictionary:system]];
        NSDictionary *user = [cacheDict objectForKey: @"User"]; 
        [installedApp addObjectsFromArray:[self desktopAppsFromDictionary:user]];
        NSLog(@"installedApp :: %@",installedApp);
    }
    else
    {
        NSLog(@"Error..");
    }
}

Credit goes to Igor Fedorchuk.

There is also one Library called AppList. You can use it on jailbroken Devices.

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94