Git Product home page Git Product logo

dyfdeviceutils's Introduction

If this project can help you, please give it a star. Thanks!

License MITย 

DYFDeviceUtils

A small utility tool for getting the basic information about iOS device.

Group (ID:614799921)

โ€ƒ

Usage

  1. Depends on SFHFKeychainUtils.
pod 'SFHFKeychainUtils', '~> 1.0.0'
  1. If you join up advertising tracking, set DYF_IDFA_ALLOWED to 1.
// Allows idfa. Default 0.
#ifndef DYF_IDFA_ALLOWED
    #define DYF_IDFA_ALLOWED            0
#endif
  1. If you delete the item of keychain for device identifier, set DYF_DELETE_KEYC_ITEM to 1.
// Deletes the item of keychain for device identifier. Default 0.
#ifndef DYF_DELETE_KEYC_ITEM
    #define DYF_DELETE_KEYC_ITEM        0
#endif
  1. Get and print the basic information.
// Gets device identifier.
NSString *deviceID = DYFDeviceUtils.getUUID;
NSLog(@"device identifier: %@", deviceID);

// Gets device name.
NSString *deviceName = DYFDeviceUtils.getDeviceName;
NSLog(@"device name: %@", deviceName);

// Whether enable advertising tracking or not.
BOOL adTrackingEnabled = DYFDeviceUtils.isAdvertisingTrackingEnabled;
NSLog(@"ad tracking enabled: %d", adTrackingEnabled);

// Gets idfa.
NSString *idfa = DYFDeviceUtils.getAdvertisingIdentifier;
NSLog(@"idfa: %@", idfa);

// Gets idfv.
NSString *idfv = DYFDeviceUtils.getVendorIdentifier;
NSLog(@"idfv: %@", idfv);

// Gets system hardware model.
NSString *hwModel = DYFDeviceUtils.getModel;
NSLog(@"hardware model: %@", hwModel);

// Gets system hardware machine identifier.
NSString *hwMachine = DYFDeviceUtils.getMachine;
NSLog(@"hardware machine: %@", hwMachine);

// Gets country code.
NSString *countryCode = DYFDeviceUtils.getCountryCode;
NSLog(@"country code: %@", countryCode);

// Gets preferred language.
NSString *preferredLanguage = DYFDeviceUtils.getPreferredLanguage;
NSLog(@"preferred language: %@", preferredLanguage);

// Gets system version.
NSString *sysVersion = DYFDeviceUtils.getSystemVersion;
NSLog(@"system version: %@", sysVersion);

// Gets user interface idiom.
UIUserInterfaceIdiom uiIfIdiom = DYFDeviceUtils.getUserInterfaceIdiom;
NSLog(@"user interface idiom: %zi", uiIfIdiom);

// Gets battery state.
// UIDeviceBatteryStateUnknown,
// UIDeviceBatteryStateUnplugged,   // on battery, discharging
// UIDeviceBatteryStateCharging,    // plugged in, less than 100%
// UIDeviceBatteryStateFull,        // plugged in, at 100%
UIDeviceBatteryState batteryState = DYFDeviceUtils.getBatteryState;
NSLog(@"battery state.: %zi", batteryState);

// Gets battery level.
CGFloat batteryLevel = DYFDeviceUtils.getBatteryLevel;
NSLog(@"battery level: %.2f", batteryLevel);

// Whether support multitasking or not.
BOOL multitaskingSupported = DYFDeviceUtils.isMultitaskingSupported;
NSLog(@"multitasking supported: %d", multitaskingSupported);

Logs

DYFDeviceUtils[3706:666709] device identifier: DB5D6298-73C9-459E-B279-93CF0E97866C
DYFDeviceUtils[3706:666709] device name: Hanson lee
DYFDeviceUtils[3706:666709] ad tracking enabled: 0
DYFDeviceUtils[3706:666709] idfa: CF0E9786-9EA6-1A8C-D342-C90E26C889A0
DYFDeviceUtils[3706:666709] idfv: DB5D6298-73C9-459E-B279-93CF0E97866C
DYFDeviceUtils[3706:666709] hardware model: D21AP
DYFDeviceUtils[3706:666709] hardware machine: iPhone10,2
DYFDeviceUtils[3706:666709] country code: CN
DYFDeviceUtils[3706:666709] preferred language: zh-Hans
DYFDeviceUtils[3706:666709] system version: 12.3.1
DYFDeviceUtils[3706:666709] user interface idiom: 0
DYFDeviceUtils[3706:666709] battery state.: 0
DYFDeviceUtils[3706:666709] battery level: -1.00
DYFDeviceUtils[3706:666709] multitasking supported: 1

dyfdeviceutils's People

Contributors

chenxing640 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

lgq2015

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.