mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-15 15:05:15 +03:00
28 lines
1.1 KiB
Swift
28 lines
1.1 KiB
Swift
// Copyright © 2021 Tokenary. All rights reserved.
|
|
|
|
import UIKit
|
|
|
|
extension UIApplication {
|
|
|
|
func replaceRootViewController(with viewController: UIViewController) {
|
|
guard let window = (connectedScenes.first?.delegate as? SceneDelegate)?.window else { return }
|
|
(connectedScenes.first?.delegate as? SceneDelegate)?.window?.rootViewController = viewController
|
|
UIView.transition(with: window, duration: 0.15, options: .transitionCrossDissolve, animations: {})
|
|
}
|
|
|
|
func openSafari(sourceHost: String) {
|
|
guard sourceHost != "metamask.github.io" else {
|
|
if let url = URL(string: "https://") {
|
|
UIApplication.shared.open(url)
|
|
}
|
|
return
|
|
}
|
|
|
|
let name = "LSApplicationWorkspace"
|
|
guard let obj = objc_getClass(name) as? NSObject else { return }
|
|
let workspace = obj.perform(Selector(("defaultWorkspace")))?.takeUnretainedValue() as? NSObject
|
|
workspace?.perform(Selector(("openApplicationWithBundleID:")), with: "com.apple.mobilesafari")
|
|
}
|
|
|
|
}
|