解决方案 »

  1.   

    用到私有API了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;
      NSLog(@"relativeCachePath:%@",relativeCachePath);
      // 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;
        NSLog(@"path:%@",path);
        // Ensure that file exists
        if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir] && !isDir){
          cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
        } 
        
        // If cache is loaded, then break the loop. If the loop is not "broken," it will return NO later (default: case)
        if (cacheDict){
          NSLog(@"cacheDict:%@",cacheDict);
          break;
        } 
        
      }
      
      NSLog(@"gggg");
      // First check all system (jailbroken) apps
      NSDictionary *system = [cacheDict objectForKey: @"System"]; 
      NSLog(@"system:%@",system);
      if ([system objectForKey: bundleIdentifier]){
        return YES;
      }
      
      // Then all the user (App Store /var/mobile/Applications) apps
      NSDictionary *user = [cacheDict objectForKey: @"User"]; 
      NSLog(@"user:%@",user);
      if ([user objectForKey: bundleIdentifier]){
        return YES;
      }
      
      // If nothing returned YES already, we'll return NO now
      return NO;
    }
      

  2.   

    先谢谢了,找到了Itunes的API可以找到一部分的,私有的还没有尝试~