---
title: "getActiveWindow(completionHandler:)"
framework: safariservices
role: symbol
role_heading: Type Method
path: "safariservices/sfsafariapplication/getactivewindow(completionhandler:)"
---

# getActiveWindow(completionHandler:)

Calls the completion handler with the active browser window.

## Declaration

```swift
class func getActiveWindow(completionHandler: @escaping @Sendable (SFSafariWindow?) -> Void)
```

```swift
class func activeWindow() async -> SFSafariWindow?
```

## Parameters

- `completionHandler`: A block to call when the active browser window is returned.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: class func activeWindow() async -> SFSafariWindow? For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. If there is no active Safari window, the value of activeWindow is nil, and the completion handler is not called.

## See Also

### Working with Windows

- [openWindow(with:completionHandler:)](safariservices/sfsafariapplication/openwindow(with:completionhandler:).md)
- [showPreferencesForExtension(withIdentifier:completionHandler:)](safariservices/sfsafariapplication/showpreferencesforextension(withidentifier:completionhandler:).md)
