美文网首页
iOS设备型号和App版本号

iOS设备型号和App版本号

作者: 青椒辣不辣 | 来源:发表于2022-01-24 17:28 被阅读0次

    设备型号

    #import <sys/utsname.h>

    设备表链接

    struct utsname systemInfo;
    uname(&systemInfo);
    
    NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
        
    NSLog(@"%@",deviceModel);
    // eg: [@"iPhone12,1" @"iPhone11"]; [@"iPhone12,3" @"iPhone 11 Pro"]; [@"iPhone12,5" @"iPhone 11 Pro Max"];
    
    

    NSBundle

    NSBundle *bundle = [NSBundle mainBundle];
        
    NSLog(@"%@",[bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]);// eg: GRJAPP
    NSLog(@"%@",[bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);// eg: 1.0
    NSLog(@"%@",[bundle objectForInfoDictionaryKey:@"CFBundleVersion"]);// eg: 1
    
    

    bundle.infoDictionary App信息

    {
        BuildMachineOSBuild = 20E241;
        CFBundleDevelopmentRegion = en;
        CFBundleDisplayName = GRJAPP;
        CFBundleExecutable = RJMarkNote;
        CFBundleIdentifier = "HualinSecurities.RJMarkNote";
        CFBundleInfoDictionaryVersion = "6.0";
        CFBundleName = RJMarkNote;
        CFBundleNumericVersion = 16809984;
        CFBundlePackageType = APPL;
        CFBundleShortVersionString = "1.0";
        CFBundleSupportedPlatforms =     (
            iPhoneOS
        );
        CFBundleVersion = 1;
        DTCompiler = "com.apple.compilers.llvm.clang.1_0";
        DTPlatformBuild = 19A339;
        DTPlatformName = iphoneos;
        DTPlatformVersion = "15.0";
        DTSDKBuild = 19A339;
        DTSDKName = "iphoneos15.0";
        DTXcode = 1300;
        DTXcodeBuild = 13A233;
        LSRequiresIPhoneOS = 1;
        MinimumOSVersion = "15.0";
        NSCameraUsageDescription = "\U4ee5\U4fbf\U4f7f\U7528\U62cd\U7167\U529f\U80fd\U83b7\U53d6\U56fe\U7247\U8bbe\U7f6e\U7528\U6237\U5934\U50cf\U4ee5\U53ca\U53d1\U5e03\U52a8\U6001\U7b49";
        NSContactsUsageDescription = "\U4ee5\U4fbf\U5feb\U901f\U586b\U5199\U8054\U7cfb\U4eba\U4fe1\U606f";
        NSLocationAlwaysUsageDescription = "\U4ee5\U4fbf\U83b7\U53d6\U9644\U8fd1\U7684\U4eba";
        NSLocationWhenInUseUsageDescription = "\U4ee5\U4fbf\U83b7\U53d6\U9644\U8fd1\U7684\U4eba";
        NSMicrophoneUsageDescription = "\U4ee5\U4fbf\U5728\U4e2a\U4eba\U8d44\U6599\U6216\U8005\U804a\U5929\U4e2d\U53d1\U9001\U8bed\U97f3";
        NSPhotoLibraryAddUsageDescription = "\U4ee5\U4fbf\U4f60\U53ef\U4ee5\U4fdd\U5b58\U4f60\U559c\U6b22\U7684\U56fe\U7247";
        NSPhotoLibraryUsageDescription = "\U7528\U4e8e\U9009\U53d6\U76f8\U518c\U4e2d\U7684\U56fe\U7247\U8bbe\U7f6e\U7528\U6237\U5934\U50cf\U4ee5\U53ca\U53d1\U5e03\U52a8\U6001\U7b49";
        UIApplicationSceneManifest =     {
            UIApplicationSupportsMultipleScenes = 0;
            UISceneConfigurations =         {
                UIWindowSceneSessionRoleApplication =             (
                                    {
                        UISceneConfigurationName = "Default Configuration";
                        UISceneDelegateClassName = SceneDelegate;
                        UISceneStoryboardFile = Main;
                    }
                );
            };
        };
        UIApplicationSupportsIndirectInputEvents = 1;
        UIDeviceFamily =     (
            1,
            2
        );
        UILaunchStoryboardName = LaunchScreen;
        UIMainStoryboardFile = Main;
        UIRequiredDeviceCapabilities =     (
            arm64
        );
        UISupportedInterfaceOrientations =     (
            UIInterfaceOrientationPortrait,
            UIInterfaceOrientationLandscapeLeft,
            UIInterfaceOrientationLandscapeRight
        );
    }
    
    
    

    UIDevice 设备信息

    UIDevice *device = [UIDevice currentDevice];
    
    @property(nonatomic,readonly,strong) NSString    *name;              // e.g. "My iPhone"
    @property(nonatomic,readonly,strong) NSString    *model;             // e.g. @"iPhone", @"iPod touch"
    @property(nonatomic,readonly,strong) NSString    *localizedModel;    // localized version of model
    @property(nonatomic,readonly,strong) NSString    *systemName;        // e.g. @"iOS"
    @property(nonatomic,readonly,strong) NSString    *systemVersion;     // e.g. @"4.0"
    @property(nonatomic,readonly) UIDeviceBatteryState  batteryState API_AVAILABLE(ios(3.0)) API_UNAVAILABLE(tvos);  // UIDeviceBatteryStateUnknown if monitoring disabled
    @property(nonatomic,readonly) float                 batteryLevel API_AVAILABLE(ios(3.0)) API_UNAVAILABLE(tvos);  // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown
    
    
    NSLog(@"%@",device.name);//SHAiPhone
    NSLog(@"%@",device.model);//iPhone
    NSLog(@"%@",device.localizedModel);//iPhone
    NSLog(@"%@",device.systemName);//iOS
    NSLog(@"%@",device.systemVersion);//15.0
    NSLog(@"%ldf",device.batteryState);//0f
    NSLog(@"%.2f",device.batteryLevel);//-1.00
    
    

    相关文章

      网友评论

          本文标题:iOS设备型号和App版本号

          本文链接:https://www.haomeiwen.com/subject/elgbhrtx.html