I'm presenting a SFSafariViewController
by calling presentViewController:animated:completion:
on a UIViewController
instance.
The result is that it gets pushed on (slides in from the right), as if I called pushViewController:animated:
on a UINavigationController
instance. I've verified that this is all happening on the main queue. And the presenting view controller is not a modal itself (which shouldn't matter anyways, but just in case, we can rule that out).
If I substitute the SFSafariViewController
with a UIViewController
, it works as expected, it presents modally.
weakSelf.oAuthViewController = [[SFSafariViewController alloc] initWithURL:url]; [viewController presentViewController:weakSelf.oAuthViewController animated:YES completion:nil];
Any idea why or how to work around this?
A common approach to place the SFSafariViewController inside SwiftUI is to create a simple view representing a SFSafariViewController , then present it with a sheet(isPresented:onDismiss:content:) modifier or a NavigationLink button (See ContentView. swift in the demo project).
SFSafariViewController no longer shares cookies with the standalone Safari browser. Thus, a website can no longer determine that the user on SFSafariViewController is the same user on Safari, even though the view controller and the browser are open on the same device.
Safari View Controller's job is to make it fast, easy and enjoyable for users to tap on a link within your app, view a web page and press done to go right back to your app. Safari View Controller eliminates distractions. The URL field that you see up there, it's read only.
Here's a simple way to obtain a vertical modal presentation of a SFSafariViewController
:
let safari = SFSafariViewController(URL: url) safari.modalPresentationStyle = .overFullScreen presentViewController(safari, animated: true, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With