Magsafe accessory detection on iphone 12

I'm looking to set a flag or trigger an event within an app when a mag safe accessory is connected to the device (i.e. phone case). is there a way to do this in xcode? I did not find anything related to magsafe in the documentation but since the phone reacts to a device being connected, I suspect there is a way to monitor this.

Any support from Apple on this?

Magsafe accessory detection on iphone 12
 
 
Q