Deep Linking Overview
Relevant source files
The following files were used as context for generating this wiki page:
The Deep Linking system in Social-Connect provides a mechanism to handle external URLs and route them to specific features within the application. This system allows the app to respond to external triggers—such as web links or notifications—by navigating to specific user profiles, posts, or triggering social actions like following a user.
The architecture relies on the AppDelegate to intercept incoming URLs, which are then passed to a dedicated DeepLinkHandler. This handler parses the URL components and coordinates with services like UserService to execute business logic or update the UI state.
Core Architecture
The deep linking flow begins when the iOS operating system passes a URL to the application. The system is designed with a clear separation of concerns between URL reception, parsing, and execution.
Application Entry Point
The AppDelegate acts as the primary receiver for deep links. It overrides the standard UIApplicationDelegate method to capture incoming URLs and forwards them to the specialized handler.
Sources: AppDelegate.swift:14-17
URL Parsing and Routing
The DeepLinkHandler is responsible for decomposing the URL into its constituent parts (host and query items). It uses a switch mechanism based on the URL host to determine the intended destination or action.
Sources: DeepLinkHandler.swift:8-25
The diagram above illustrates the routing logic from the initial application entry point to the specific handler methods based on the URL host.
Sources: AppDelegate.swift:16, DeepLinkHandler.swift:14-24
Deep Link Actions and Endpoints
The system supports several specific actions defined by the URL host and query parameters.
| Host | Parameter | Action |
|---|---|---|
profile | userId | Navigates the app to the specific user's profile page. |
follow | userId | Triggers an automated follow request for the specified user. |
message | N/A | Opens the messaging interface (Implementation pending). |
post | N/A | Opens a specific post (Implementation pending). |
Sources: DeepLinkHandler.swift:16-43
Follow Action Logic
When a "follow" deep link is processed, the system extracts the userId from the query items and invokes the UserService. This triggers a network request via the APIClient.
This sequence shows how a deep link action transitions from the handler through the service layer to an authenticated API call.
Sources: DeepLinkHandler.swift:31-35, UserService.swift:9-15, APIClient.swift:15-20
Service Integration
User Service & Networking
The UserService handles the business logic for social interactions triggered by deep links. It communicates with the APIClient to perform HTTP POST requests to endpoints such as users/{userId}/follow.
Sources: UserService.swift:7-13
Security and Authentication
Deep link actions that require network interaction are secured using the KeychainManager. When the APIClient processes a request initiated by a deep link, it retrieves a stored "authToken" to include in the "Authorization" header.
if let token = KeychainManager.shared.getAuthToken() {
request.addValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
}
Sources: APIClient.swift:15-18, KeychainManager.swift:11-20
Summary
Deep linking in Social-Connect is a structured pipeline that converts external URL triggers into internal application actions. By centralizing the logic in DeepLinkHandler, the application ensures that navigation and social actions (like following users) are handled consistently while maintaining security through the KeychainManager and service-based networking architecture.