iOS - execute code on microphone events

Hello, I'm working on an iOS app whose purpose is to execute an HTTP POST request when the user starts/finishes a call (mobile call or a VOIP call via Skype, Teams and similar).

The main scenario is: there is a REST server that is in charge of managing the volume of a radio. Radio volume should be lowered when someone in the room is busy in a call and then restored when no one is at the phone.

My idea is to react when the microphone is activated/deactivated and execute the HTTP request to the server.

Is there anything I can use to notice when these two events occurs (even if the app is in background/closed) ? Some sort of notifications or native event from the O.S. I could register to?

I found this question: https://developer.apple.com/forums/thread/76731, but no answer has been reported (it's a 4 years old topic). I don't need to know which app is using the microphone, I only need to know that the microphone is in use and execute a very small code.

Thanks in advance

How would you make the difference between ambience noise and someone speaking in a call ?    Did you see this ?     https://stackoverflow.com/questions/66947908/how-to-detect-external-microphone-by-swift-5-in-simulator

I don't mind. If the microphone is in use it means that there is an active call, so I have to tell the server that it must lower the volume of music. I don't want to register anything. The very important thing is that I don't want to keep polling the mic status, because the app could be in background or closed. I need to react to some sort of O.S. event that says "Hey, microphone is in use!" or "Hey, the microphone is no more in use!"

iOS - execute code on microphone events
 
 
Q