I have a SFSafariViewController which opens when a user taps on a link in my app. I need to detect when the URL is changed, such that when it changes, the app displays an alert. How do we detect URL changes in SFSafariViewController?
You cannot do this.
SFSafariViewController
is meant to send users off to a browser without caring too much where she goes to, but when she's done, she'll be right back in your app without any loss of context. There's only very few things you can customize.
The official docs mention (emphasis mine):
If your app lets users view websites from anywhere on the Internet, use the SFSafariViewController class. If your app customizes, interacts with, or controls the display of web content, use the WKWebView class.
It will require more work (especially some UI) to provide a nice browsing experience using WKWebView
, but you're in control. The same goes for the older sibling, UIWebView
. If you don't know which to use, this comparison might help, although some things may have improved on the side of WKWebView
since the article was written.
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