2011-08-29 4 views
24

설치된 모든 앱 (NSArray)의 목록을보고 싶습니다. 내 응용 프로그램은 감옥에있는 응용 프로그램이며/응용 프로그램에 있으므로 샌드 박스는 아무런 문제가 없습니다. 앱 스토어 앱 목록을 가져 오는 방법이 있습니까? 나는 이미 다른 앱 (Activator, SBSettings ...)에서 이것을 보았습니다. 모든 응용 프로그램 샌드 박스에는 거대한 코드가 있기 때문에이를 수행하는 방법을 모릅니다. 따라서 샌드 박스 내부의 .app 폴더에 액세스하는 것이 어떻게 가능할 지 모르겠습니다.설치된 모든 앱 목록보기

답변

13

이 코드를 사용할 수 있습니다

도의 더러운 일을 모두 수행 할 AppList library,있다
#import "InstalledAppReader.h" 

static NSString* const installedAppListPath = @"/private/var/mobile/Library/Caches/com.apple.mobile.installation.plist"; 

@interface InstalledAppReader() 

-(NSArray *)installedApp; 
-(NSMutableDictionary *)appDescriptionFromDictionary:(NSDictionary *)dictionary; 

@end 


@implementation InstalledAppReader 

#pragma mark - Init 
-(NSMutableArray *)desktopAppsFromDictionary:(NSDictionary *)dictionary 
{ 
    NSMutableArray *desktopApps = [NSMutableArray array]; 

    for (NSString *appKey in dictionary) 
    { 
     [desktopApps addObject:appKey]; 
    } 
    return desktopApps; 
} 

-(NSArray *)installedApp 
{  
    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]]; 

     return installedApp; 
    } 

    DLOG(@"can not find installed app plist"); 
    return nil; 
} 

@end 
+0

이 비공개 API는 비공개 API입니까? – iJatrat

+5

이것은 비공개 API는 아니지만 개인 폴더에 액세스 할 수 있습니다. Apple은 귀하의 앱을 거부합니다. jailbroken iPhone에만이 코드를 사용하십시오. – Igor

+2

@Fedorchuk, 어떻게 정상적인 IOS 장치 에서이 설치된 응용 프로그램 목록을 얻을 수 있나요 jailbroken 아이폰, PLZ이 일을하지 않고 의미. – maddysan

6

jailbroken 아이폰에서는 /Applications 폴더를 읽을 수 있습니다. 설치된 모든 응용 프로그램이 나타납니다. 그냥 NSFileManager를 사용 /Applications에서 디렉토리를 나열 :

NSArray *appFolderContents = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Applications"]; 
+1

미리 설치된 앱과 cydia 앱만 읽습니다. 앱 스토어 앱에 대해 이야기하고 있습니다. – JonasG

+1

'mobile' 사용자의 응용 프로그램 폴더를 시도해보십시오.'/ private/var/mobile/Applications' –

+0

@ BjörnMarschollek : 정말 고마워요. 나는 많은 도움이되었다. – Pushkraj

2

을 내가 iHasApp라는 프레임 워크를 발견 한 몇 가지 조사 후. 다음은 응용 프로그램 이름, 식별자와 아이콘이있는 사전을 반환 할 수있는 좋은 솔루션입니다 : Finding out what Apps are installed

2

당신 : rpetrich/AppList 그것은 많은 본때를 보여 주는 조정에서 사용 되었기 때문에 왜 여기에 제안되지 않았는지 모르겠습니다.

단지 AppStore 앱을 얻는 한 가지 방법은 목록에 표시된 각 앱에 대해 isSystemApplication 값을 확인하는 것입니다. NO으로 설정된 값은 일반 AppStore 앱입니다. 의 기능도 있으므로 목록을 미리 필터링 할 수도 있습니다.

관련 문제