从捆绑ID获取应用名称

我有安装在设备上的应用程序的捆绑ID列表,我想获得应用程序名称。 解决scheme应该在没有监狱破碎的设备上工作。 该应用程序不会去应用程序商店,所以应用程序拒绝不metter。


我发现这个解决scheme,它会返回应用程序的详细信息,如果它位于应用程序商店。 http://itunes.apple.com/lookup?bundleId=com.bundle.id

大多数时候,你可以得到这个…

NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey]; 

编辑:

正如你想find所有的应用程序。

 NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:(id)kCFBundleExecutableKey]; NSLog(@"AppName: %@",appName); 

这应该做到这一点。

 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"]; NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; 

方法

 - (NSString *)titleOfAppWithBundleIdentifier:(NSString *)bundleIdentifier { NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier]; return [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"]; } 

所有捆绑信息在这里:

 NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary]); NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"]; 

bundleInfo倾倒

 { BuildMachineOSBuild = ...; CFBundleDevelopmentRegion = ...; CFBundleDisplayName = ...; CFBundleExecutable = ...; CFBundleIcons = { CFBundlePrimaryIcon = { CFBundleIconFiles = ( "AppIcon29x29.png", "AppIcon29x29@2x.png", "AppIcon40x40@2x.png", "AppIcon57x57.png", "AppIcon57x57@2x.png", "AppIcon60x60@2x.png", "AppIcon60x60@3x.png" ); UIPrerenderedIcon = 1; }; }; CFBundleIdentifier = ...; CFBundleInfoDictionaryVersion = ...; CFBundleInfoPlistURL = ...; CFBundleName = ...; CFBundleNumericVersion = 0; CFBundlePackageType = APPL; CFBundleShortVersionString = ...; CFBundleSignature = "????"; CFBundleSupportedPlatforms = ( iPhoneOS ); CFBundleVersion = "1.0.11"; DTCompiler = ...; DTPlatformBuild = ...; DTPlatformName = iphoneos; DTPlatformVersion = "8.3"; DTSDKBuild = ...; DTSDKName = "iphoneos8.3"; DTXcode = ...; DTXcodeBuild = ...; LSRequiresIPhoneOS = 1; MinimumOSVersion = "5.1"; UIBackgroundModes = ( ..., ... ); UIDeviceFamily = ( 1 ); UILaunchImageFile = LaunchImage; UILaunchImages = ( { UILaunchImageMinimumOSVersion = "7.0"; UILaunchImageName = ...; UILaunchImageOrientation = Portrait; UILaunchImageSize = "{320, 568}"; } ); UIMainStoryboardFile = Main; UIRequiredDeviceCapabilities = ( armv7 ); UISupportedInterfaceOrientations = ( UIInterfaceOrientationPortrait ); UIViewControllerBasedStatusBarAppearance = 0; } 

如果您想获取本地化的包显示名称,请使用localizedInfoDictionary

 NSString *appName = [[NSBundle mainBundle] localizedInfoDictionary][@"CFBundleDisplayName"]; 
 NSString *appName = [[bundleID componentsSeparatedByString:@"."] lastObject]; 

假设bundleID是反向的dns格式..

我相信这应该给你答案:

 NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:@"CFBundleExecutable"];