Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add referrerUrl #5706

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion ios/Capacitor/Capacitor/CAPApplicationDelegateProxy.swift
Expand Up @@ -5,6 +5,7 @@ public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate {
public static let shared = ApplicationDelegateProxy()

public private(set) var lastURL: URL?
public private(set) var referrerUrl: URL?

public func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
NotificationCenter.default.post(name: .capacitorOpenURL, object: [
Expand All @@ -24,8 +25,10 @@ public class ApplicationDelegateProxy: NSObject, UIApplicationDelegate {

let url = userActivity.webpageURL
lastURL = url
referrerUrl = userActivity.referrerURL
NotificationCenter.default.post(name: .capacitorOpenUniversalLink, object: [
"url": url
"url": url,
"referrerUrl": referrerUrl
])
return true
}
Expand Down
4 changes: 4 additions & 0 deletions ios/Capacitor/Capacitor/CAPBridge.swift
Expand Up @@ -10,6 +10,10 @@ import Foundation
public static func getLastUrl() -> URL? {
return ApplicationDelegateProxy.shared.lastURL
}

public static func getReferrerUrl() -> URL? {
return ApplicationDelegateProxy.shared.referrerUrl
}

public static func handleOpenUrl(_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
return ApplicationDelegateProxy.shared.application(UIApplication.shared, open: url, options: options)
Expand Down