Post

Replies

Boosts

Views

Activity

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
1
2
363
Jul ’24