Code Monkey home page Code Monkey logo

device's Introduction

Device

Device provides a platform-agnostic framework for accessing device details, including the device name, model, operating system version, processor count, and thermal state.

In addition, Device includes a Battery class for monitoring the battery level of the device. This class is an observable object with published properties, making it easy to track changes in the battery level, charging state, low power mode, etc. over time.

Features

  • Access to device details such as name, model, and operating system version
  • Cross-platform support for macOS, iOS, tvOS, watchOS
  • Battery monitoring with the Battery class
  • Thermal state monitoring

Installation

You can add the Device framework to your project via Swift Package Manager. Simply go to File > Swift Packages > Add Package Dependency and enter the following URL: https://github.com/pmanot/Device.

Usage

To access device details and monitor the battery level, create an instance of the Device class: swift

import Device
let device = Device.current

You can then access the various properties of the Device class, such as the device name and model:

print(device.name) // "iPhone" 
print(device.model) // "iPhone"

You can also monitor changes in the thermal state of the device:

device.$thermalState.sink { thermalState in 
      print("Thermal state changed: \(thermalState)")
}
.store(in: &cancellables)

Finally, you can monitor the battery level with the Battery class:

let battery = Battery()

battery.$level.sink { level in 
      print("Battery level changed: \(level)") 
}
.store(in: &cancellables)

Contributing

Contributions are welcome! If you find a bug or have a feature request, please create an issue. If you want to contribute code, please create a pull request.

License

Device is available under the MIT license. See the LICENSE file for more info.

device's People

Contributors

pmanot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

device's Issues

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.