kikinteractive/DeviceKit

Name: DeviceKit

Owner: Kik Interactive

Description: DeviceKit is a value-type replacement of UIDevice.

Forked from: rounds/DeviceKit

Created: 2017-01-16 17:39:15.0

Updated: 2017-01-16 17:39:18.0

Pushed: 2016-10-25 07:24:35.0

Homepage:

Size: 162

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

GitHub license Build Status CocoaPods Compatible Carthage Compatible Platform

Device is a value-type replacement of UIDevice.

Features
Requirements
Installation

DeviceKit can be installed in various ways.

CocoaPods
ce 'https://github.com/CocoaPods/Specs.git'
form :ios, '8.0'
frameworks!

'DeviceKit', '~> 0.3.5'
Carthage
ub "dennisweissmann/DeviceKit" ~> 0.3.5
Manually

To install it manually drag the DeviceKit project into your app project in Xcode or add it as a git submodule. In your project folder enter:

t submodule add https://github.com/dennisweissmann/DeviceKit.git
Usage

Here are some usage examples. All devices are also available as simulators:

one6 => .Simulator(.iPhone6)
one6s => .Simualtor(.iPhone6s)

etc.

Get the Device You're Running On
device = Device()

t(device)     // prints, for example, "iPhone 6 Plus"

evice == .iPhone6Plus {
// Do something
se {
// Do something else

Get the Device Family
device = Device()
evice.isPod {
// iPods (real or simulator)
se if device.isPhone {
/ iPhone (real or simulator)
se if device.isPad {
/ iPad (real or simulator)

To check if running on Simulator
device = Device()
evice.isSimulator {
// Running on one of the simulators(iPod/iPhone/iPad) 
// Skip doing something irrelevant for Simulator

Get the Simulator Device
device = Device()
ch device {
 .Simulator(.iPhone6s): break // You're running on the iPhone 6s simulator
 .Simulator(.iPadAir2): break // You're running on the iPad Air 2 simulator
ult: break

Make Sure the Device Is Contained in a Preconfigured Group
groupOfAllowedDevices: [Device] = [.iPhone6, .iPhone6Plus, .iPhone6s, .iPhone6sPlus, .Simulator(.iPhone6), .Simulator(.iPhone6Plus), .Simulator(.iPhone6s), .Simulator(.iPhone6sPlus)]
device = Device()

evice.isOneOf(groupOfAllowedDevices) {
// Do you action

Get the Current Battery State
evice.batteryState == .Full || device.batteryState >= .Charging(75) {
print("Your battery is happy! ?")

Get the Current Battery Level
evice.batteryLevel >= 50 {
install_iOS()
se {
showError()

Contributing

If you have the need for a specific feature that you want implemented or if you experienced a bug, please open an issue. If you extended the functionality of DeviceKit yourself and want others to use it too, please submit a pull request.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.