         openPortal(path: "/account")
     }
     
-    func openPortal(path: String) {
+    func openPortal(path: String, openWithApplication: URL? = nil) {
         let portalURLString = "\(portalBaseUrl())\(path)"
         os_log("Opening portal with String: %{public}@", log: log, type: .info, portalURLString)
         let portalURLWithSecretString = "\(portalURLString)#coreAPIPassword=\(createOrRetrieveCoreWalletPassword())"
         let portalURLWithSecretAndLogPortString = "\(portalURLWithSecretString)&logServerPort=\(logServerPort)"
         let portalURLWithSecretLogPortAndRegtest = "\(portalURLWithSecretAndLogPortString)&regtest=\(isRegTestModeEnabled ? 1 : 0)"
         let portalURL = URL(string: portalURLWithSecretLogPortAndRegtest)
-        NSWorkspace.shared().open(portalURL!)
+        
+        if (openWithApplication != nil) {
+            do {
+                try NSWorkspace.shared().open(
+                    [portalURL!],
+                    withApplicationAt: openWithApplication!,
+                    options: .default,
+                    configuration: [:]
+                )
+            } catch {
+                os_log("Error opening URL with app: %{public}@", log: log, type: .error, openWithApplication!.absoluteString)
+                NSWorkspace.shared().open(portalURL!)
+            }
+        } else {
+            NSWorkspace.shared().open(portalURL!)
+        }
+        
     }
 
     func statusItemClick(sender: AnyObject?) {

    }
    
    func handleGetURLEvent(_ event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
        let url = (event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue) ?? ""
        let authRequest = url.replacingOccurrences(of: "blockstack:", with: "")
        os_log("Blockstack URL: %{public}@", log: log, type: .info, url)
        os_log("Blockstack Auth Request: %{public}@", log: log, type: .debug, authRequest)

        openPortal(path: "\(portalAuthenticationPath)\(authRequest)")

    }



    let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Default")

    func applicationWillFinishLaunching(_ notification: Notification) {
        // This must be registered before `applicationDidFinishLaunching` otherwise the event
        // may not be triggered if Blockstack.app was not already running.
        let appleEventManager = NSAppleEventManager.shared()
        appleEventManager.setEventHandler(self, andSelector: #selector(handleGetURLEvent), forEventClass: UInt32(kInternetEventClass), andEventID: UInt32(kAEGetURL))
    }
    
    func applicationDidFinishLaunching(_ aNotification: Notification) {
        os_log("applicationDidFinishLaunching: %{public}@", log: log, type: .default, blockstackDataURL().absoluteString)

