On my app I used to present programmatically an UIAlert with the following code:
debugPrint("didReceiveInvitationFromPeer")
let fieldAlert = UIAlertController(title: "Richiesta di conssessione",
message: "da parte di (peerID.displayName)",
preferredStyle: .alert)
fieldAlert.addAction( UIAlertAction(title: "Rifiuta", style: .cancel) { (action) in
invitationHandler(false, nil)
} )
fieldAlert.addAction( UIAlertAction(title: "accetta", style: .default) { (action) in
invitationHandler(true, self.session)
delay(2) {
// do stuff
}
} )
if let scene = UIApplication.shared.connectedScenes.first,
let sd : SceneDelegate = (scene.delegate as? SceneDelegate) {
sd.window?.rootViewController?.present(fieldAlert, animated: true, completion: nil)
}
but now SceneDelegate not exists anymore, is there any solution to how can present the alert?
question from:
https://stackoverflow.com/questions/65912280/how-can-i-update-my-app-code-using-swiftui-2-where-there-is-no-scenedelegate 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…