Which class we should use? WKWebView or SFSafariViewController

UIWebViewClass was deprecated and we need to replace it with WKWebView or SFSafariViewController. Which class we should use?

I think we use WKWebView normally, but SFSafariViewController has enough functionality in some case.


It is decided which class can be used by requirements.

  1. You want to do something just before or after loading pages.
  2. You want to know the URL of loading pages.
  3. You want to execute JavaScript on loaded pages.

If you want to do above, you need to use WKWebView. SFSafariViewController can not do above.

Requirements are really needed?

“We want to do something just after loading pages.”. It is often available requirement but it is really needed?

For example, “something” is that opening specific URL or closing the page with JavaScript. You can place the “Close” button on the navigation bar in the SFSafariViewController.

If you want to know the URL of loaded pages to check the authorization status, you can set the redirect URL to the application custom URL scheme and UIApplicationDelegate can handle it. It is able to do with SFSafariViewController.

Launching the browser is really good?

It is bad UX that launching Safari with sign-up page to create the account. After the account was created, user sign in in the app. User go and come between your app and Safari. It can’t be say good UX.

It is better opening the sign-up page with SFSafariViewController than launching Safari, I think.


Sponsored Links
Get the Latest News !