Skip to main content

why-not-use-webviews-in-native-apps

Why Use SFSafariViewController or Custom Chrome Tab Instead of WebViews in Native Apps

Using SFSafariViewController on iOS or Custom Chrome Tab on Android instead of traditional webviews like UIWebView or WKWebView on iOS, and WebView on Android, provides several advantages, especially in terms of performance, security, and user experience. Here are the key reasons why developers might choose these technologies for integrating web content into their native apps:

1. User Experience Consistency

  • SFSafariViewController and Custom Chrome Tab utilize the same browser engine as Safari and Chrome respectively. This ensures that web content behaves the same way it would in a standard browser, providing a consistent and predictable user experience.
  • These views also support browser features like AutoFill, content blockers, and saved passwords, which are not available in traditional webviews.

2. Security

  • SFSafariViewController and Custom Chrome Tab offer enhanced security. Because they run in separate processes, they isolate the web content from the app, reducing the risk of security vulnerabilities affecting the native application.
  • They also inherit the browser's security features such as intelligent tracking prevention in Safari and Google’s Safe Browsing in Chrome.

3. Authentication and Cookies

  • With SFSafariViewController and Custom Chrome Tab, cookies and other local data are shared with the browser. This means that if a user is already logged into a service in their browser, they will be logged in within the app as well. This is particularly useful for social logins or any form of OAuth authentication.
  • Traditional webviews, in contrast, do not share cookies with the browser, which can lead to a disjointed experience where users might need to repeatedly log in.

4. Performance and Resource Management

  • Both SFSafariViewController and Custom Chrome Tab leverage the browser's performance optimizations such as the JIT compiler for JavaScript, which are generally more sophisticated than those in webviews.
  • They also manage memory and processes more efficiently. When the user closes the browser view, all resources are released, unlike some webview implementations that can retain memory longer than necessary.

5. Access to Newer Web Features

  • Browsers like Safari and Chrome frequently update to support the latest web standards and features. By using SFSafariViewController or Custom Chrome Tab, apps can immediately benefit from these improvements without needing to update the webview component itself.
  • Webviews might not always have the most current web engine version, leading to compatibility issues with newer web technologies.

6. Less Maintenance

  • Using these browser-based views means that developers don’t need to manage updates to the web rendering engine; it's handled by the browser app (Safari or Chrome), which is typically kept up-to-date by the user or device manufacturer.
  • This reduces the maintenance overhead for developers who would otherwise need to keep the webview components updated within their apps.

7. Google Play Compliance

  • For Android, using Custom Chrome Tab can help with compliance on Google Play, as it aligns with Google's recommended approach for displaying web content and can facilitate better app performance and feature usage tracking.

Overall, while webviews are still useful for certain types of app content, particularly where complete isolation from the user’s browser data is needed, SFSafariViewController and Custom Chrome Tab provide a more robust, secure, and user-friendly way to integrate web content into native applications.