import UIKit
import Muta
// In your AppDelegate or SceneDelegate
func handleDeepLink(url: URL) {
// Parse the source from the URL
let components = URLComponents(url: url, resolvingAgainstBaseURL: true)
let source = components?.queryItems?.first(where: { $0.name == "source" })?.value
// Map sources to placement IDs
let placementMap = [
"tiktok": "onboarding-tiktok",
"instagram": "onboarding-instagram",
"linkedin": "onboarding-linkedin"
]
let placementId = placementMap[source ?? ""] ?? "onboarding-default"
// Display the appropriate onboarding flow
Muta.shared.displayPlacement(
placementId: placementId,
presentingViewController: topViewController()
)
}
// Handle Universal Links
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL {
handleDeepLink(url: url)
return true
}
return false
}
// Handle URL Schemes
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
handleDeepLink(url: url)
return true
}