У меня есть функция, которая создает и отображает SFSafariViewController, который показывает страницу входа.
public func authorizeSafariEmbedded(from controller: UIViewController, at url: URL) throws -> SFSafariViewController {
safariViewDelegate = OAuth2SFViewControllerDelegate(authorizer: self)
let web = SFSafariViewController(url: url)
web.title = oauth2.authConfig.ui.title
web.delegate = safariViewDelegate as! OAuth2SFViewControllerDelegate
controller.addChild(web)
controller.view.addSubview(web.view)
web.didMove(toParent: controller)
web.view.translatesAutoresizingMaskIntoConstraints = false
if #available(iOS 11.0, *) {
web.view.topAnchor.constraint(equalTo: controller.view.safeAreaLayoutGuide.topAnchor, constant: 30).isActive = true
web.view.bottomAnchor.constraint(equalTo: controller.view.safeAreaLayoutGuide.bottomAnchor, constant: -30).isActive = true
web.view.leadingAnchor.constraint(equalTo: controller.view.safeAreaLayoutGuide.leadingAnchor, constant: 30).isActive = true
web.view.trailingAnchor.constraint(equalTo: controller.view.safeAreaLayoutGuide.trailingAnchor, constant: -30).isActive = true
} else {
// Fallback on earlier versions
}
if #available(iOS 10.0, *), let barTint = oauth2.authConfig.ui.barTintColor {
web.preferredBarTintColor = barTint
}
if #available(iOS 10.0, *), let tint = oauth2.authConfig.ui.controlTintColor {
web.preferredControlTintColor = tint
}
web.modalPresentationStyle = .fullScreen
willPresent(viewController: web, in: nil)
//controller.present(web, animated: true)
return web
}
Это называется так safariVC = try authorizer.authorizeSafariEmbedded(from: self,at: url!)
Вы заметите, что я не использую подарок, потому что это вызывает мое приложение для sh вот так Application tried to present modally an active controller
при входе в систему эта функция вызывается, здесь я хочу отклонить SFSafariViewController, поэтому я делаю
func hideSafariView(){
print ("sf \(safariVC)")
if safariVC != nil {
print("dissmis")
safariVC!.dismiss(animated: true, completion: nil)
}
}
Но это не не работает