I integrate with safariService
(SFSafariViewController
) to log in through a single sign-on password, the problem was the first time I log in using SFSafariViewController
the authentication does not complete the first time so the Safari browser still appears & can not direct into my app after authentication follow to become a success.
Another odd behavior is when I login again the authentication follow work fine & get the token then directed into my app fine so the main problem is the first time I login SFSafariViewController
does not catch the user auth.
if let url = URL(string: "url") {
let safariVC = SFSafariViewController(url: url)
safariVC.delegate = self
safariVC.dismissButtonStyle = .done
present(safariVC, animated: true, completion: nil)
}
extension DouWebViewVC: SFSafariViewControllerDelegate {
func safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
if didLoadSuccessfully {
print("didLoadSuccessfully")
// Do something with the URL here
}
}
//initialLoadDidRedirectTo
func safariViewController(_ controller: SFSafariViewController, initialLoadDidRedirectTo requestUrl: URL) {
let absoluteUrl = requestUrl.absoluteString
print("requestUrl\(requestUrl)")
}
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
print("safariViewControllerDidFinish")
}
}