<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ThreadNetwork",
  "identifier" : "/documentation/ThreadNetwork/THClient/retrieveActiveCredentialsForNearbyNetworks(completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ThreadNetwork"
    ],
    "preciseIdentifier" : "c:objc(cs)THClient(im)retrieveActiveCredentialsForNearbyNetworksWithCompletion:"
  },
  "title" : "retrieveActiveCredentialsForNearbyNetworks(completion:)"
}
-->

# retrieveActiveCredentialsForNearbyNetworks(completion:)

Requests all active Thread credentials with active border routers around from the framework.

```
func retrieveActiveCredentialsForNearbyNetworks(completion: @escaping @Sendable (Set<THCredentials>?, (any Error)?) -> Void)
```

```
var activeCredentialsForNearbyNetworks: Set<THCredentials> { get async throws }
```

## Parameters

`completion`

The completion handler the framework calls when the
credentials become available.

## Discussion

When calling this method, you will receive credentials for active border routers around.
You receive all credentials agnostic to team ID.
Unlike [`retrieveAllActiveCredentials(_:)`](/documentation/ThreadNetwork/THClient/retrieveAllActiveCredentials(_:)), this method returns active credentials
on the device regardless of who actually stored it.

> Note: This method asks for user permission to share available credentials.
> If user denies the permission then the completion will contain error with code 15.

> Concurrency Note: 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:
> 
> ```swift
> var activeCredentialsForNearbyNetworks: Set<THCredentials> { get async throws }
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)