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-1676 Fix custom url links from dApps #361

Merged
merged 2 commits into from
Jan 24, 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
4 changes: 2 additions & 2 deletions unstoppable-ios-app/Dev-Env-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string>com.unstoppabledomains.manager</string>
<key>CFBundleURLSchemes</key>
<array>
<string>unstoppable</string>
<string>unstoppabledomains</string>
</array>
</dict>
<dict>
Expand All @@ -53,7 +53,7 @@
<string>kleverwallet</string>
<string>mathwallet</string>
<string>metamask</string>
<string>rainbow</string>
<string>rainbow</string>
<string>okex</string>
<string>celo</string>
<string>zel</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ extension String {
return self
}
}

extension String {
func deletingPrefix(_ prefix: String) -> String? {
guard self.hasPrefix(prefix) else { return nil }
return String(self.dropFirst(prefix.count))
}
}
4 changes: 2 additions & 2 deletions unstoppable-ios-app/domains-manager-ios/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<string>com.unstoppabledomains.manager</string>
<key>CFBundleURLSchemes</key>
<array>
<string>unstoppable</string>
<string>unstoppabledomains</string>
</array>
</dict>
<dict>
Expand Down Expand Up @@ -56,7 +56,7 @@
<string>mathwallet</string>
<string>metamask</string>
<string>rainbow</string>
<string>okex</string>
<string>okex</string>
<string>celo</string>
<string>zel</string>
<string>fuse.cash</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class DeepLinksService {
private var listeners: [DeepLinkListenerHolder] = []
private let deepLinkPath = "/mobile"
private let wcScheme = "wc"
private let customURLScheme = "unstoppabledomains"
private var isExpectingWCInteraction = false

init(externalEventsService: ExternalEventsServiceProtocol,
Expand Down Expand Up @@ -158,12 +159,16 @@ private extension DeepLinksService {
func isWCDeepLinkUrl(from components: NSURLComponents) -> Bool {
(components.path == deepLinkPath) ||
(components.path == (deepLinkPath + "/" + wcScheme)) ||
(components.scheme == wcScheme)
(components.scheme == wcScheme) || (components.scheme == customURLScheme)
}

func parseWalletConnectURL(from components: NSURLComponents, in url: URL) -> URL? {
if components.scheme == wcScheme {
if components.scheme == wcScheme{
return url
} else if (components.scheme == customURLScheme),
let query = components.query,
let urlExtracted = query.deletingPrefix("uri=") {
return URL(string: urlExtracted)
} else if isWCDeepLinkUrl(from: components),
let params = components.queryItems,
let uri = params.findValue(forDeepLinkKey: DeepLinksParameterKey.uri),
Expand All @@ -172,7 +177,7 @@ private extension DeepLinksService {
}
return nil
}

func handleWCDeepLink(_ incomingURL: URL, receivedState: ExternalEventReceivedState) {
externalEventsService.receiveEvent(.wcDeepLink(incomingURL), receivedState: receivedState)
}
Expand Down