Giter Site home page Giter Site logo

tiger6688 / gbdeviceinfo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lmirosevic/gbdeviceinfo

0.0 2.0 0.0 624 KB

Detects the hardware, software and display of the current iOS or Mac OS X device at runtime.

License: Apache License 2.0

Ruby 4.23% Objective-C 95.77%

gbdeviceinfo's Introduction

GBDeviceInfo logo

Detects the hardware, software and display of the current iOS or Mac OS X device at runtime.

Versionย License

iOS

Simple usage (examples on iPhone 6 running iOS 8.1.3):

[[GBDeviceInfo deviceInfo] isOperatingSystemAtLeastVersion:@"8.0"]; // #> YES

[GBDeviceInfo deviceInfo].isJailbroken;                             // #> NO

[GBDeviceInfo deviceInfo].model;                                    // #> GBDeviceModeliPhone6
[GBDeviceInfo deviceInfo].family;                                   // #> GBDeviceFamilyiPad

[GBDeviceInfo deviceInfo].modelString;                              // #> @"iPhone 6"
[GBDeviceInfo deviceInfo].osVersion.major;                          // #> 8
[GBDeviceInfo deviceInfo].osVersion.minor;                          // #> 1

[GBDeviceInfo deviceInfo].displayInfo.pixelsPerInch;                // #> 326

You can also reuse the returned object to save some typing. First assign the object to some variable:

GBDeviceInfo *deviceInfo = [GBDeviceInfo deviceInfo];

Then get whatever you like from the object:

//Model numbers
NSLog(@"Major device ver: %d", deviceInfo.deviceVersion.major);     // Major device ver: 7
NSLog(@"Major device ver: %d", deviceInfo.deviceVersion.minor);     // Minor device ver: 2


//Specific model
if (deviceInfo.model == GBDeviceModeliPhone6) {
    NSLog(@"It's a 6");                                             // It's a 6
}

//Family of device
if (deviceInfo.family != GBDeviceFamilyiPad) {
    NSLog(@"It's not an iPad");                                     // It's not an iPad
}

//Screen type
if (deviceInfo.display == GBDeviceDisplayiPhone47Inch) {
    NSLog(@"4.7 Inch display");                                     // 4.7 Inch display
}

//iOS Version
if (deviceInfo.majoriOSVersion >= 6) {
    NSLog(@"We've got iOS 6+");                                     // We've got iOS 6+
}

//Raw systemInfo string
NSLog(@"systemInfo: %@", deviceInfo.rawSystemInfoString);           // systemInfo: iPhone7,2

Don't forget to import header.

#import <GBDeviceInfo/GBDeviceInfo.h>

Missing a property you need? Submit a Pull Request or contact [email protected]!

OS X

Simple usage (examples on a Mac Pro with an Ivy Bridge 3770K processor running 10.8.2):

[[GBDeviceInfo deviceInfo] isOperatingSystemAtLeastVersion:@"10.8"]; // #> YES

[GBDeviceInfo deviceInfo].osVersion.major;                           // #> 10
[GBDeviceInfo deviceInfo].osVersion.minor;                           // #> 8
[GBDeviceInfo deviceInfo].family == GBDeviceFamilyMacPro;            // #> YES
[GBDeviceInfo deviceInfo].isMacAppStoreAvailable;                    // #> YES
[GBDeviceInfo deviceInfo].isIAPAvailable;                            // #> YES

You can also reuse the returned object to save some typing. First assign the object to some variable:

GBDeviceInfo *deviceInfo = [GBDeviceInfo deviceInfo];

Then get whatever you like from the object:

GBDeviceInfo *deviceInfo = [GBDeviceInfo deviceInfo];

//OS X Version
if (deviceInfo.osVersion.minor >= 8) {
    NSLog(@"It's OS X 10.8+ (Mountain Lion)");                     // It's OS X 10.8+ (Mountain Lion)
}
if (deviceInfo.osVersion.patch == 2) {
    NSLog(@"Must be running x.x.2");                               // Must be running x.x.2
}

//App Store stuff
if (deviceInfo.isMacAppStoreAvailable) {
    NSLog(@"App store is available.");                             // App store is available
}
if (deviceInfo.isIAPAvailable) {
    NSLog(@"...and so are IAPs");                                  // ...and so are IAPs
}

//Hardware stuff
NSLog(@"SystemInfo: %@", deviceInfo.rawSystemInfoString);          // SystemInfo: MacPro3,1
NSLog(@"Major device ver: %d", deviceInfo.deviceVersion.major);    // Major device ver: 3
NSLog(@"Minor device ver: %d", deviceInfo.deviceVersion.minor);    // Minor device ver: 1
NSLog(@"Node name: %@", deviceInfo.nodeName);                      // Node name: MyMac.local
NSLog(@"RAM: %.3f GB", deviceInfo.physicalMemory);                 // RAM: 16.000 GB
NSLog(@"CPU freq: %.3f GHz", deviceInfo.cpu.frequency);            // CPU freq: 3.500 GHz
NSLog(@"Number of cores: %d", deviceInfo.cpu.numberOfCores);       // Number of cores: 8
NSLog(@"L2 Cache size: %.0f KB", deviceInfo.cpu.l2CacheSize);      // L2 Cache size: 256 KB

//Endianness
if (deviceInfo.byteOrder == GBByteOrderLittleEndian) {
    NSLog(@"Little Endian");                                       // Little Endian
}

//Family of device
if (deviceInfo.family != GBDeviceFamilyMacBookAir) {
    NSLog(@"It's not a Macbook Air");                              // It's not a Macbook Air
}

//Screen resolution
if (deviceInfo.screenResolution.width == 1920 && deviceInfo.screenResolution.height == 1200) {
    NSLog(@"Resolution: 1920x1200");                              // Resolution: 1920x1200
}

Don't forget to import framework:

#import <GBDeviceInfo/GBDeviceInfo.h>

Missing a property you need? Submit a Pull Request or contact [email protected]!

iOS Device support

  • iPhone1
  • iPhone3G
  • iPhone3GS
  • iPhone4
  • iPhone4S
  • iPhone5
  • iPhone5C
  • iPhone5S
  • iPhone6
  • iPhone6Plus
  • iPad1
  • iPad2
  • iPad3
  • iPad4
  • iPadMini1
  • iPadMini2
  • iPadMini3
  • iPadAir1
  • iPadAir2
  • iPod1
  • iPod2
  • iPod3
  • iPod4
  • iPod5
  • iPhone Simulator
  • iPad Simulator

OS X Device family support

  • iMac
  • MacMini
  • MacPro
  • MacBook
  • MacBookAir
  • MacBookPro
  • Xserve

Changelog

February 2015 update

  • Backwards incompatible API changes (bumped major version to 3.x.x)
  • Big refactor and cleanup of the public interface
  • Internal logic is much cleaner and easier for future maintenance
  • Better documentation
  • Fixed all known bugs
  • Replaced some deprecated API calls, with fallbacks
  • Consolidated related values into structs

November 2013 update

  • Added new devices: iPhone 5C, iPhone5S, iPad Mini Retina, iPad Air

June 2013 update

  • iOS version now has support for simulator detection
  • iOS version can now return a human readable string for the device, e.g. "iPhone 4S"

May 2013 update

  • OSX version now has methods for checking whether the App Store and/or IAP are available on the machine

March 2013 update

  • iOS version now returns an object instead of a struct, so you should declare your variables as GBDeviceInfo *deviceInfo instead of the old static way GBDeviceInfo deviceInfo
  • Some properties in iOS lib have been renamed:
    • iOSVersion -> majoriOSVersion
    • bigModelNumber -> majorModelNumber
    • smallModelNumber -> minorModelNumber
  • New properties have been added in iOS lib:
    • minoriOSVersion
    • rawSystemInfoString
  • rawSystemInfoString method has been removed (you get the same string from the returned object now)

Author

Luka Mirosevic (@lmirosevic)

Enterprise

Premium support, integration, use-case adaptations and consulting available. Contact [email protected].

Copyright & License

Copyright 2015 Goonbee

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

gbdeviceinfo's People

Contributors

lmirosevic avatar fcanas avatar jalmaas-agens avatar christophercotton avatar vijayhike avatar mhupman avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.