NSArray *App_id;
NSMutableArray *App_ExistId;
NSMutableArray *App_Name;
NSMutableArray *App_version;
NSMutableArray *App_path;
// Implementation
- (void)GetInstalledAppInfo
{
App_id = [[NSArray alloc] initWithObjects:@"com.shinhan.sbank", nil]; //찾을 앱의 BundleIdentifier
App_ExistId = [[NSMutableArray alloc] init]; //App_id의 리스트중, 존재하는 앱의 id가 들어감
App_version = [[NSMutableArray alloc] init]; //앱의 버젼
App_path = [[NSMutableArray alloc] init]; //경로
App_Name = [[NSMutableArray alloc] init]; //표시되는 이름
NSDictionary *cacheDict = nil;
NSDictionary *app = nil;
NSString *path = nil;
path = @"/var/mobile/Library/Caches/com.apple.mobile.installation.plist"; //캐쉬 파일
BOOL isDir = NO;
if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir)
cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
NSDictionary *user = [cacheDict objectForKey: @"User"]; //시디아앱/시스템 앱을 구할때는 System 으로 변경
for (NSString *bundleIdentifier in App_id) {
app = nil;
if (app = [user objectForKey: bundleIdentifier])
{
NSLog(@"App installed: %@", bundleIdentifier);
NSLog(@"Version: %@", [app objectForKey: @"CFBundleVersion"]);
NSLog(@"Container: %@", [app objectForKey: @"Container"]);
NSLog(@"Path: %@", [app objectForKey: @"Path"]);
[App_ExistId addObject:bundleIdentifier];
[App_version addObject:[app objectForKey: @"CFBundleVersion"]];
[App_path addObject:[app objectForKey: @"Path"]];
[App_Name addObject:[app objectForKey: @"CFBundleDisplayName"]];
}else {
NSLog(@"App not installed: %@", bundleIdentifier);
}
}
}