Files
wallet/apps/mobile/ios/Lux/WalletConnect/RNWalletConnect.swift
zeekay 55a7f247ca init: extract wallet from lux/exchange monorepo
Copies apps/extension, apps/mobile and 10 pkgs (wallet, ui, config,
utilities, sessions, gating, notifications, analytics, eslint-config,
prices) into a standalone pnpm workspace.  Resolves merge conflict
markers in extension and mobile package.json files, strips build
artifacts (.wxt, .output, Pods).
2026-04-11 01:59:19 -07:00

48 lines
1.4 KiB
Swift

//
// RNWalletConnect.swift
// Lux
//
// Created by Tina Zheng on 3/4/22.
//
import Foundation
// Used to return to previously opened app (wallet to dapp in mobile browser)
@objc private protocol PrivateSelectors: NSObjectProtocol {
var destinations: [NSNumber] { get }
func sendResponseForDestination(_ destination: NSNumber)
}
@objc(RNWalletConnect)
class RNWalletConnect: NSObject {
/*
* Open the previously opened app that deep linked to Lux app
* (eg. Dapp website in Safari -> Wallet -> Dapp website in Safari).
* Returns false and does nothing if there is no previous opened app to link back to.
* Returns true if successfully opened previous app
*/
@objc
func returnToPreviousApp() -> Bool {
let sys = "_system"
let nav = "Navigation"
let action = "Action"
guard
let sysNavIvar = class_getInstanceVariable(UIApplication.self, sys + nav + action),
let action = object_getIvar(UIApplication.shared, sysNavIvar) as? NSObject,
let destinations = action.perform(#selector(getter: PrivateSelectors.destinations)).takeUnretainedValue() as? [NSNumber],
let firstDestination = destinations.first
else {
return false
}
action.perform(#selector(PrivateSelectors.sendResponseForDestination), with: firstDestination)
return true
}
@objc static func requiresMainQueueSetup() -> Bool {
return false
}
}