Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs(auth): handle incoming deep link URLs on Swift (#48774)

Guilherme Souzaa18ee934cd5e
diff --git a/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx b/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx
index e08ddeb5567..b21b0f44898 100644
--- a/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx
+++ b/apps/docs/content/guides/auth/native-mobile-deep-linking.mdx
@@ -345,6 +345,70 @@ With Deep Linking, you can configure this redirect to open a specific page. This
</plist>
```
+### Handling the incoming URL
+
+ Once the OS opens your app via the redirect URL, pass that URL to `supabase.auth.handle(_:)` to complete the sign-in.
+
+ #### SwiftUI
+
+ Use the `onOpenURL` view modifier on your root view:
+
+ ```swift
+ SomeView()
+ .onOpenURL { url in
+ supabase.auth.handle(url)
+ }
+ ```
+
+ #### UIKit: App delegate
+
+ Forward the URL from `application(_:open:options:)`, and from `didFinishLaunchingWithOptions` if the app was launched cold via the link:
+
+ ```swift
+ func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+ ) -> Bool {
+ if let url = launchOptions?[.url] as? URL {
+ supabase.auth.handle(url)
+ }
+
+ return true
+ }
+
+ func application(
+ _ app: UIApplication,
+ open url: URL,
+ options: [UIApplication.OpenURLOptionsKey: Any]
+ ) -> Bool {
+ supabase.auth.handle(url)
+ return true
+ }
+ ```
+
+ #### UIKit: Scene delegate
+
+ Forward the URL from `SceneDelegate.swift`, handling both a cold launch (via `scene(_:willConnectTo:options:)`) and a URL received while the scene is already running (via `scene(_:openURLContexts:)`):
+
+ ```swift
+ func scene(
+ _ scene: UIScene,
+ willConnectTo session: UISceneSession,
+ options connectionOptions: UIScene.ConnectionOptions
+ ) {
+ for context in connectionOptions.urlContexts {
+ supabase.auth.handle(context.url)
+ }
+ }
+
+ func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
+ guard let url = URLContexts.first?.url else { return }
+ supabase.auth.handle(url)
+ }
+ ```
+
+ `handle(_:)` is a convenience wrapper that calls `session(from:)` and logs any error. See the [Auth API reference](/docs/reference/swift/auth-api) for details, or call `session(from:)` directly if you need the returned `Session` or want control over error handling.
+
<$Partial path="universal_links_apple.mdx" />
</TabPanel>
diff --git a/supa-mdx-lint/Rule003Spelling.toml b/supa-mdx-lint/Rule003Spelling.toml
index 37ede15dfc7..5930697ca85 100644
--- a/supa-mdx-lint/Rule003Spelling.toml
+++ b/supa-mdx-lint/Rule003Spelling.toml
@@ -419,6 +419,7 @@ allow_list = [
"Transformers.js",
"tsquery",
"Twilio",
+ "UIKit",
"Undici",
"UnionPay",
"Unsplash",