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

MOB-2043 - Handle ud.me/wallet deep link #567

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ private extension CoreAppCoordinator {
Task { await router.showDomainProfile(domain, wallet: wallet, preRequestedAction: action) }
case .showPublicDomainProfile(let publicDomainDisplayInfo, let wallet, let action):
Task { await router.showPublicDomainProfileFromDeepLink(of: publicDomainDisplayInfo, by: wallet, preRequestedAction: action) }
case .activateMPCWallet:
router.runAddWalletFlow(initialAction: .activateMPC)
}
default: return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ final class DeepLinksService {
private let coreAppCoordinator: CoreAppCoordinatorProtocol
private var listeners: [DeepLinkListenerHolder] = []
private let deepLinkPath = "/mobile"
private let ud_me_MPC_path = "wallet"
private let wcScheme = "wc"
private let customURLScheme = "unstoppabledomains"
private var isExpectingWCInteraction = false
Expand All @@ -38,6 +39,9 @@ extension DeepLinksService: DeepLinksServiceProtocol {
}
} else if let domainName = DomainProfileLinkValidator.getUDmeDomainName(in: components) {
tryHandleUDDomainProfileDeepLink(domainName: domainName, params: components.queryItems, receivedState: receivedState)
} else if isActivateMPCWalletDeepLink(components: components) {
notifyWaitersWith(event: .activateMPCWallet,
receivedState: receivedState)
} else {
tryHandleWCDeepLink(from: components, incomingURL: incomingURL, receivedState: receivedState)
}
Expand Down Expand Up @@ -190,6 +194,19 @@ private extension DeepLinksService {
receivedState: receivedState)
}

func isActivateMPCWalletDeepLink(components: NSURLComponents) -> Bool {
guard let path = components.path,
let host = components.host else { return false }

let pathComponents = path.components(separatedBy: "/")

if Constants.udMeHosts.contains(host),
pathComponents.last == ud_me_MPC_path {
return true
}
return false
}

func notifyWaitersWith(event: DeepLinkEvent, receivedState: ExternalEventReceivedState) {
Debugger.printInfo(topic: .UniversalLink, "Did receive deep link event \(event)")
listeners.forEach { holder in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum DeepLinkEvent: Equatable {
case mintDomainsVerificationCode(email: String, code: String)
case showUserDomainProfile(domain: DomainDisplayInfo, wallet: WalletEntity, action: PreRequestedProfileAction?)
case showPublicDomainProfile(publicDomainDisplayInfo: PublicDomainDisplayInfo, wallet: WalletEntity, action: PreRequestedProfileAction?)
case activateMPCWallet
}

protocol DeepLinksServiceProtocol {
Expand Down