Is it possible to listen physical mute/unmute ring state?

I would really like to know if it is possible to get a state for the ringer on iOS. In my application I want to repeat the logic of audio rules from Instagram during watching a video.

The video plays with sound. When the ringer switches to mute status the video's audio should be muted too. When you press the volume up or down button the audio should be unmuted.

I found how to catch volume up/down buttons with AVAudioSession.sharedInstance().observe(\.outputVolume) but I couldn't find anything that could help me with the ringer state. AVAudioSession.Category can't achieve this effect.

Also there is a possibility to check ringer state with Darwin notify lib like

var token = NOTIFY_TOKEN_INVALID
        notify_register_dispatch(
          "com.apple.springboard.ringerstate",
          &token,
          .main
        ) { token in
          var state: UInt64 = 0
          notify_get_state(token, &state)
          print("Changed to", state == 1 ? "ON" : "OFF")
        }

but I'm not sure that this won't lead to the application being rejected. I don't know is it a private API usage or not.

I will be glad to any advice and suggestions. Thanks

I’m gonna leave the central question for others — I know precious little about audio )-: — but I want to be offer clear advice about this:

Also there is a possibility to check ringer state with Darwin notify lib

Unless otherwise documented, Darwin notify keys are not considered API. See this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is it possible to listen physical mute/unmute ring state?
 
 
Q