Skip to content

Commit

Permalink
MOB-2043 - Handle ud.me/wallet deep link (#567)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored May 27, 2024
1 parent 9f820f6 commit 48e14fd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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

0 comments on commit 48e14fd

Please sign in to comment.