[macOS 27] (Regression) IOPMPowerSource not returning a Temperature value anymore

Background

Li-ion batteries permanently lose capacity with increasing temperature. Common knowledge suggests that this effect starts to become serious at 35ºC. To my knowledge, macOS does not warn the user about this situation. Even worse, macOS in default configuration is known to be extremely conservative regarding fan noise, resulting in battery temperatures of 45ºC and higher. This negligence has led to a rich market of 3rd party apps that close this gap.

History

Fortunately, it was possible to retrieve the current battery temperature via a call to IOPMPowerSource. This was removed in macOS 27. Now you might ask, why not query the SMC or the IOHIDService? While both ways return temperature sensor information, to my knowledge this will result in a rejection from the App Store.

The Problem

How do we write an App Store compliant app for macOS 27 that warns the user about her MacBook battery overheating?

Code

App-Store compliant code pre macOS 27

CFMutableDictionaryRef matching , properties = NULL;
io_registry_entry_t entry = 0;
matching = IOServiceMatching( "IOPMPowerSource" );
entry = IOServiceGetMatchingService( kIOMainPortDefault , matching );
IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 );
	
NSDictionary psPropertyDict	= CFBridgingRelease(properties);
NSNumber *temp = psPropertyDict[@"Temperature"];

Presumably Non App Store compliant code

#import <IOKit/hidsystem/IOHIDEventSystemClient.h>
#import <IOKit/hidsystem/IOHIDServiceClient.h>

extern CFTypeRef	IOHIDServiceClientCopyEvent(IOHIDServiceClientRef, int64_t, int64_t, int64_t);

#define IOHIDEventTypeTemperature			0x0FLL

		IOHIDEventSystemClientRef client = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
		NSArray *services	= CFBridgingRelease(IOHIDEventSystemClientCopyServices(client));
		for (id o in services) {
			IOHIDServiceClientRef service	= (__bridge IOHIDServiceClientRef)o;
	CFTypeRef event		= IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0);
	NSString *sensor	= CFBridgingRelease(IOHIDServiceClientCopyProperty(service, CFSTR(kIOHIDProductKey)));
	static int64_t IOHIDEventFieldTemperatureLevel = IOHIDEventFieldBase(IOHIDEventTypeTemperature);
	
		CFTypeRef event	= IOHIDServiceClientCopyEvent(service, IOHIDEventTypeTemperature, 0, 0);
		double value	= IOHIDEventGetFloatValue(event, IOHIDEventFieldTemperatureLevel);
}

FB24621108

[macOS 27] (Regression) IOPMPowerSource not returning a Temperature value anymore
 
 
Q