P#133d – Pizzaiolo iOS

The Pizzaiolo iOS app is a hybrid food‑ordering application built with SwiftUI and a customized WKWebView wrapper, very similar in architecture to the Testo iOS app. It brings the full functionality of https://www.pizza-vl.ru to iPhone while adding native handling for calls, sharing and external apps.

At the UI level, a SwiftUI view (PizzaioloWebView – structurally similar to TestoWebView) conforms to UIViewRepresentable and embeds a WKWebView configured with:

  • WKWebViewConfiguration and WKPreferences to enable JavaScript and controlled popup behavior.
  • Optionally, a non‑persistent WKWebsiteDataStore to avoid storing cache when desired.
  • URLRequest with reloadIgnoringLocalCacheData for forced reloads of important pages.

A Coordinator implements WKNavigationDelegate and WKUIDelegate and is responsible for:

  • Updating a @Binding isLoading flag when navigation starts/finishes so the SwiftUI layer can show or hide a loading indicator.
  • Intercepting Telegram share links (tg://msg?text=…):
    • extracts and decodes the message text,
    • tries to open Telegram using the native tg:// URL scheme,
    • falls back to the web share URL (https://t.me/share/url?text=...) if Telegram is not installed.
  • Intercepting WhatsApp share links (https://api.whatsapp.com/send?text=… and https://wa.me/...):
    • parses the text query parameter or extracts it from the path,
    • percent‑encodes the message and opens whatsapp://send?text=... if WhatsApp is available,
    • otherwise falls back to opening the original web URL.
  • Handling tel:mailto: and sms: links so that phone calls, email and SMS are initiated via the respective native iOS apps instead of staying inside the web view.

Like the Testo implementation, the coordinator also:

  • Detects navigationAction.targetFrame == nil (new‑window navigations),
  • Manually loads such URLs in the main web view with a cache‑controlled URLRequest,
  • Uses simple tracking of the last manually loaded URL and timestamp to avoid duplicate loads.

The result is a smooth hybrid experience: users interact with the familiar Pizzaiolo website, but all important actions (calls, shares, external apps) behave like a native iOS app, and loading behavior can be tuned for reliability.

Tech stack: SwiftSwiftUI, WKWebView (UIViewRepresentable), Custom URL handling (Alfa‑Bank payments, custom schemes, Telegram, WhatsApp, tel:mailto:sms:)