There is a way to check if the application is installed or not, however it violates the Sandbox rules, and Apple * may reject your application to use it. But this was done previously by other applications that are available on the App Store, so feel free to try it.
, , URL, - ( / ). , Apple, -, , , . , MobileInstallation, SpringBoard Info . "" , App Store. , Simulator 2.2.1:
:
BOOL APCheckIfAppInstalled(NSString *bundleIdentifier);
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;
for (short i = 0; 1; i++)
{
switch (i) {
case 0:
path = [NSHomeDirectory() stringByAppendingPathComponent: relativeCachePath];
break;
case 1:
path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
break;
case 2:
path = [@"/var/mobile" stringByAppendingPathComponent: relativeCachePath];
break;
default:
return NO;
break; }
BOOL isDir = NO;
if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir)
cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
if (cacheDict)
break;
}
NSDictionary *system = [cacheDict objectForKey: @"System"];
if ([system objectForKey: bundleIdentifier]) return YES;
NSDictionary *user = [cacheDict objectForKey: @"User"];
if ([user objectForKey: bundleIdentifier]) return YES;
return NO;
}
, , "yourselfmadeapp" .
:
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);
:
:
2009-01-30 12: 19: 20.250 SomeApp [266: 20b] : com.apple.mobilesafari 2009-01-30 12: 19: 20.254 SomeApp [266: 20b] : com.yourcompany.yourselfmadeapp 2009-01-30 12: 19: 20.260 SomeApp [266: 20b] : com.blahblah.nonexistent
, , , Apple , MobileInstallation.plist, , , . !
http://www.iphonedevsdk.com/forum/iphone-sdk-development/37103-finding-out-what-apps-installed.html