从包ID中获取应用名称

Iva*_*lek 13 iphone objective-c ios

我有来自设备上安装的应用程序的捆绑ID的列表,我想获取应用程序名称.解决方案应该适用于不受监狱破坏的设备.该应用程序不会进入应用程序商店,因此应用程序拒绝不会满足.


我找到了这个解决方案,如果它位于应用程序商店,它将返回应用程序的详细信息. http://itunes.apple.com/lookup?bundleId=com.bundle.id

Ano*_*dya 24

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

NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];
Run Code Online (Sandbox Code Playgroud)

编辑:

您想要找到所有应用程序.

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

  • @Imran:我认为这是不可能的. (2认同)

NSA*_*ict 11

这应该做到这一点.

NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"];
NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
Run Code Online (Sandbox Code Playgroud)

方法

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


Sal*_*lim 7

所有捆绑信息都在这里:

NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary]);

NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"];
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)


小智 -3

NSString *appName = [[bundleID componentsSeparatedByString:@"."] lastObject];
Run Code Online (Sandbox Code Playgroud)

假设bundleID是反向dns格式。

  • 这并不是很聪明,因为 BundleID 可能完全不同。 (9认同)