12.8 추가
새 방법은 앱스토어에서 사용가능한 방식입니다.
자세한건 새 글에서 소개..
====================
쨋든 심사부터 통과못하는 것같고, 통과하더라도 작동하지 않는 듯...
canOpenURL 을 통해 여부를 확인하는걸 가장 추천하지만 여의치 않을때는....에라 모르겠다..ㅋ
====================
앱의 설치 여부를 알수 있는 소스. Bundle ID를 이용하며,
코딩은 이것저것 배려되어 있지만 상당수 제거해버려도 큰 상관이 없다...
원리는 
/var/mobile/Library/Caches/com.apple.mobile.installation.plist
파일에 모든 데이터가 기록되어 있다는 것을 이용.
사실 이것만 알면 아래 소스는 큰 필요가 없다.
코딩하기 귀찮을때 사용하자..ㅋㅋ
// Declaration
BOOL APCheckIfAppInstalled(NSString *bundleIdentifier); // Bundle identifier (eg. com.apple.mobilesafari) used to track apps
// Implementation
BOOL APCheckIfAppInstalled(NSString *bundleIdentifier)
{
	static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
	NSString *relativeCachePath = [[@"Library" stringByAppendingPathComponent: @"Caches"] stringByAppendingPathComponent: cacheFileName];
	NSDictionary *cacheDict = nil;
	NSString *path = nil;
	// Loop through all possible paths the cache could be in
	for (short i = 0; 1; i++)
	{
	
		switch (i) {
	case 0: // Jailbroken apps will find the cache here; their home directory is /var/mobile
		path = [NSHomeDirectory() stringByAppendingPathComponent: relativeCachePath];
		break;
	case 1: // App Store apps and Simulator will find the cache here; home (/var/mobile/) is 2 directories above sandbox folder
		path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
		break;
	case 2: // If the app is anywhere else, default to hardcoded /var/mobile/
		path = [@"/var/mobile" stringByAppendingPathComponent: relativeCachePath];
		break;
	default: // Cache not found (loop not broken)
		return NO;
		break; }
		
		BOOL isDir = NO;
		if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir) // Ensure that file exists
			cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
		
		if (cacheDict) // If cache is loaded, then break the loop. If the loop is not "broken," it will return NO later (default: case)
			break;
	}
	
	NSDictionary *system = [cacheDict objectForKey: @"System"]; // First check all system (jailbroken) apps
	if ([system objectForKey: bundleIdentifier]) return YES;
	NSDictionary *user = [cacheDict objectForKey: @"User"]; // Then all the user (App Store /var/mobile/Applications) apps
	if ([user objectForKey: bundleIdentifier]) return YES;
	
	// If nothing returned YES already, we'll return NO now
	return NO;
}
Here is an example of this, assuming that your app is named "yourselfmadeapp" and is an app in the app store. 
Code:
NSArray *bundles2Check = [NSArray arrayWithObjects: @"com.apple.mobilesafari", @"com.yourcompany.yourselfmadeapp", @"com.blahblah.nonexistent", nil];
for (NSString *identifier in bundles2Check)
	if (APCheckIfAppInstalled(identifier))
		NSLog(@"App installed: %@", identifier);
	else
		NSLog(@"App not installed: %@", identifier);'개발개발 > Mac, iOS' 카테고리의 다른 글
| Xcode - Device Log 보기 (0) | 2011.02.23 | 
|---|---|
| BundleIdentifier로 앱 정보 구하기 (4) | 2011.02.23 | 
| DEBIAN PACKAGING (deb) 만들기 (수정) (1) | 2011.01.30 | 
| PreferenceLoader 사용법 (0) | 2011.01.30 | 
| MobileSubstrate Extension with XCode (0) | 2011.01.07 |