mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
Start WalletConnect session from universal link
This commit is contained in:
parent
f8edfb066f
commit
af48f91ebc
@ -76,12 +76,16 @@ class Agent {
|
||||
statusBarItem.button?.sendAction(on: [.leftMouseUp])
|
||||
}
|
||||
|
||||
func processInputLink(_ link: String) {
|
||||
let session = WalletConnect.shared.sessionWithLink(link)
|
||||
showInitialScreen(onAppStart: false, wcSession: session)
|
||||
}
|
||||
|
||||
@objc private func statusBarButtonClicked(sender: NSStatusBarButton) {
|
||||
let pasteboard = NSPasteboard.general
|
||||
let link = pasteboard.string(forType: .string) ?? ""
|
||||
pasteboard.clearContents()
|
||||
let session = WalletConnect.shared.sessionWithLink(link)
|
||||
showInitialScreen(onAppStart: false, wcSession: session)
|
||||
processInputLink(link)
|
||||
}
|
||||
|
||||
private func proceedAfterAuthentication(reason: String, completion: @escaping (Bool) -> Void) {
|
||||
|
@ -5,24 +5,29 @@ import Cocoa
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
private let agent = Agent.shared
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
Agent.shared.start()
|
||||
Agent.shared.setupStatusBarItem()
|
||||
agent.start()
|
||||
agent.setupStatusBarItem()
|
||||
}
|
||||
|
||||
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||
Agent.shared.reopen()
|
||||
agent.reopen()
|
||||
return true
|
||||
}
|
||||
|
||||
func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool {
|
||||
if let url = userActivity.webpageURL?.absoluteString {
|
||||
print(url)
|
||||
let prefix = "https://encrypted.ink/wc?uri="
|
||||
if let url = userActivity.webpageURL?.absoluteString, url.hasPrefix(prefix),
|
||||
let link = url.dropFirst(prefix.count).removingPercentEncoding {
|
||||
agent.processInputLink(link)
|
||||
}
|
||||
// TODO: do something if could not parse input link
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user