Using IOKit in macOS app

Gusev Slava

I found several topics where arises the same question, but they're pretty old and most of them don't have a definite answer, or the answer is applicable to iOS only. Also some sources say it's prohibited while other disagree.

For example, here or here about iOS.

I'm interested whether IOKit can be used for macOS applications - note! macOS, not iOS - to get only battery information.

If no, I'd like to find out, how apps like Battery Health work.

What are your guesses? Thanks.

pmdj

The IOKit.framework is a reasonably well documented, public API on macOS. Many apps and most 3rd party device drivers use it. For the Mac App Store, entitlements restrictions apply.

Regarding Mac battery status, you probably want to take a look at the IOPMPowerSource/AppleSmartBattery objects. The output from running the following command on the Terminal should give you an idea of what information is available:

ioreg -w 0 -irc IOPMPowerSource

The AppleSmartBattery source code is available, that's probably your best reference.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to change mouse settings programmatically in macOS using IOKit

Using `decltype` in IOKit code

Implementing USB read timeout on MacOS and IOKit

Using IOKit to communicate with USB device

Adding IOKit from Xcode.app bundle

How can I link IOKit using theos?

Adding a custom font to macOS app using Swift

Check if an app is installed on MacOS using the Terminal

Should I use IOKit or DriverKIt (or HIDDriverKit) to write driver for USB or Bluetooth multi-touch device in macOS?

Error when enabling auto login of macOS app using a helper

Open app and pass parameters with deep linking using Electron (macOS)

How do I add a toolbar to a macOS app using SwiftUI?

Activate Electron app on MacOS using Cmd+tab

How do you save a .txt file using Swift 3 on a USB if it is connected using filemanager? (macOS app development)

Is there an alternative to macOS that runs macOS .app files?

How to execute code before my macOS app starts and prevent it from starting upon some condition using SwiftUI?

Is there any way to control the width of the search field as it's being added to the toolbar while using .searchable on a macOS app?

Flutter clean and flutter run doesn't rebuild the app on macOS using Visual Studio Code

Can I upload an app to the iOS AppStore using Xcode 9 and macOS Mojave?

Using AppleScript to export individual photo titles to text file from MacOS Photos App

In a MacOS App using SwiftUI, how to modify the default blue background of a selected NavigationLink nested in a list?

How can I silently install a MacOS .app from a dmg, using a single command?

How to sign-in to a google account inside my app without using a UX (on macos)

Deleting App / NSUserDefaults data on macOS

Sort macOS Mail App conversations

Deep link into macOS app is not recognized

Debugging JavascriptCore with safari, in Macos app

WKWebView popup is not working in MacOS app

Using Caffeinate command in MacOS