---
title: "getActiveTab(completionHandler:)"
framework: safariservices
role: symbol
role_heading: Instance Method
path: "safariservices/sfsafariwindow/getactivetab(completionhandler:)"
---

# getActiveTab(completionHandler:)

Calls the completion handler with the active tab in the target window.

## Declaration

```swift
func getActiveTab(completionHandler: @escaping @Sendable (SFSafariTab?) -> Void)
```

```swift
func activeTab() async -> SFSafariTab?
```

## Parameters

- `completionHandler`: A block called after the active tab is retrieved.

## 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: func activeTab() async -> SFSafariTab? For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Working with Tabs

- [openTab(with:makeActiveIfPossible:completionHandler:)](safariservices/sfsafariwindow/opentab(with:makeactiveifpossible:completionhandler:).md)
