Skip to content

Commit

Permalink
MOB-1676 Fix custom url links from dApps (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
rommex authored Jan 24, 2024
1 parent e04d0b4 commit 55f6e64
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
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

0 comments on commit 55f6e64

Please sign in to comment.