Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- web.modalPresentationStyle = oauth2.authConfig.ui.modalPresentationStyle
- willPresent(viewController: web, in: nil)
- controller.present(web, animated: false,completion: nil)
- return web
- }
Advertisement
Add Comment
Please, Sign In to add comment