---
title: "isPreferredNetworkAvailable(completion:)"
framework: threadnetwork
role: symbol
role_heading: Instance Method
path: "threadnetwork/thclient/ispreferrednetworkavailable(completion:)"
---

# isPreferredNetworkAvailable(completion:)

Indicates whether a preferred network is available.

## Declaration

```swift
func isPreferredNetworkAvailable(completion: @escaping @Sendable (Bool) -> Void)
```

```swift
func isPreferredAvailable() async -> Bool
```

## Parameters

- `completion`: The completion handler that returns the result of the preferred network status.

## Mentioned in

Configuring a Border Router Managing Thread network credentials

## Discussion

Discussion 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: func isPreferredAvailable() async -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. Call the method as follows: func obtainPreferredAvailable() async -> (NSString?) {     let client = THClient()     var bIsPreferredAvailable:Bool?     bIsPreferredAvailable = await client.isPreferredAvailable()     let str = ((bIsPreferredAvailable == true) ? "true" : "false")     return str as NSString; }

## See Also

### Retrieving Credentials

- [checkPreferredNetwork(forActiveOperationalDataset:completion:)](threadnetwork/thclient/checkpreferrednetwork(foractiveoperationaldataset:completion:).md)
- [retrieveCredentials(forBorderAgent:completion:)](threadnetwork/thclient/retrievecredentials(forborderagent:completion:).md)
- [retrieveCredentials(forExtendedPANID:completion:)](threadnetwork/thclient/retrievecredentials(forextendedpanid:completion:).md)
- [retrieveAllCredentials(_:)](threadnetwork/thclient/retrieveallcredentials(_:).md)
- [retrievePreferredCredentials(_:)](threadnetwork/thclient/retrievepreferredcredentials(_:).md)
- [retrieveAllActiveCredentials(_:)](threadnetwork/thclient/retrieveallactivecredentials(_:).md)
