79348073

Date: 2025-01-11 12:34:46
Score: 0.5
Natty:
Report link

I think a combination of solutions is needed here. But it is certain that the "Ring/Silent switch" is controlled via "Audio Session Categories".

import SwiftUI
import AVFoundation

#if os(iOS)
    let AV_SESSION = AVAudioSession.sharedInstance()
#endif

@main struct app: App {

    var body: some Scene {
        WindowGroup {
            ...
        }
    }

    init() {
        #if os(iOS)
            try! AV_SESSION.setActive(true)
            try! AV_SESSION.setCategory(.playback)
        #endif
    }

}

Links:

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Maxim Rysevets