Thursday, October 29, 2026
HomeiOS Developmentios - Proceed rendering SceneKit whereas AVAudioSession.requestRecordPermission modal is exhibiting

ios – Proceed rendering SceneKit whereas AVAudioSession.requestRecordPermission modal is exhibiting

[ad_1]

I’ve a easy SceneKit iOS app. Whereas the app is working, I have to immediate the consumer for microphone permissions utilizing requestRecordPermission:

AVAudioSession.sharedInstance().requestRecordPermission(...)

This appropriately exhibits a permissions modal dialog but it surely additionally pauses the rendering of my app till the dialog is dismissed by the consumer

Is there a technique to maintain my app rendering within the background even whereas this modal is exhibiting?


Thus far I’ve seemed into UIViewController.modalPresentationStyle however couldn’t get it working as anticipated with this modal

This is a easy UIViewController that demonstrates the difficulty:

import UIKit
import AVKit
import SceneKit

class ViewController: UIViewController {
    
    var scnView: SCNView!
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        
        let textRoot = SCNNode()
        
        self.scnView = SCNView(body: self.view.body)
        self.scnView.scene = SCNScene()
        self.view.addSubview(self.scnView)
        self.scnView.scene?.rootNode.addChildNode(textRoot)
        self.scnView.allowsCameraControl = true
      
        Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { t in
            for little one in textRoot.childNodes {
                little one.removeFromParentNode()
            }
            
            let textual content = SCNNode(geometry: SCNText(string: "(Date().timeIntervalSince1970)", extrusionDepth: 0.1))
            textual content.geometry?.firstMaterial?.diffuse.contents = UIColor.pink
            textRoot.addChildNode(textual content)
        })
    }

    override func viewDidAppear(_ animated: Bool) {
        tremendous.viewDidAppear(animated)
        
        Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false, block: { _ in
            AVAudioSession.sharedInstance().requestRecordPermission({ granted in })
        })
    }
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments