Back to all

URL-scheme return from OAuth works, but the Safari View Controller stays open — how to dismiss it?

We wrapped a Lovable app (Driven Bridge, co.median.ios.rdokrnz) with Median. Google sign-in runs through Lovable's OAuth broker (oauth.lovable.app via a same-origin /~oauth path), which Google won't allow inside the WKWebView, so it has to run in Safari.

What we learned (may help the other Lovable threads here):

  1. Universal Links do NOT fire on the broker's server-side redirect — the return landed in the Safari window with the "Open in app" banner instead of the app.
  2. A URL Scheme Protocol does work. Important detail: entering "drivenbridge" in the Median field registers CFBundleURLSchemes "drivenbridge.http" and "drivenbridge.https" — NOT the bare scheme. Our redirect_uri had to be drivenbridge.https:///native-signin. With the bare scheme iOS shows "Safari cannot open the page because the address is invalid." We confirmed this by reading Info.plist from the IPA.
  3. With that fixed, the handoff works: the app receives the URL and the session is installed.

Remaining problem: our link rule for the OAuth hop is "External", which on iOS opens a Safari View Controller. After the drivenbridge.https:// handoff, the app comes to the front but the Safari View Controller stays presented (blank) on top, and the user has to tap X to see the app.

Questions:

  • Is there a Median setting or JavaScript Bridge call that dismisses the Safari View Controller when the app receives a URL-scheme open?
  • Or an option for "External" to launch the Safari app rather than SFSafariViewController, so the return simply switches apps?
  • If neither exists today, is this on the roadmap? It's the last step for a clean native sign-in for Lovable-built apps.

Thanks.