---
title: "presentAskToShareUI(scanProvider:)"
framework: wifiinfrastructure
role: symbol
role_heading: Instance Method
path: "wifiinfrastructure/winetworksharingprovider/presentasktoshareui(scanprovider:)"
---

# presentAskToShareUI(scanProvider:)

Presents system UI asking people to share available networks with an accessory.

## Declaration

```swift
func presentAskToShareUI(scanProvider: (@Sendable (ASAccessory, WINetworkSharingProvider.AccessoryScanRequest) async -> WINetworkSharingProvider.AccessoryScanResponse?)? = nil) async throws -> WINetworkSharingAskToShareState
```

## Parameters

- `scanProvider`: The optional closure the system calls periodically to get updated scan results from the accessory. Returns networks your accessory discovers to help people select compatible, high-performance networks. Defaults to nil when your accessory provides no scan information. The closure receives: accessory: The ASAccessory configured for this provider. scanRequest: An AccessoryScanRequest containing scan parameters. Returns: An AccessoryScanResponse with accessory scan results, or nil when no changes occurred since the previous results.

## Return Value

Return Value The WINetworkSharingAskToShareState, indicating a response from the person.

## Discussion

Discussion Call this method when your accessory needs additional networks or when the system indicates new shareable networks are available. The system checks for nearby known networks and prompts people to select networks to share with your accessory. Your app extension can present sharing UI in these scenarios: New networks available: The system sets newShareableNetworkAvailable to true when networks become available for sharing. Your extension can verify with your accessory whether it needs additional networks before calling this method. Your container app doesn’t need to be in the foreground for this scenario. Accessory requests: Your accessory can communicate directly with your extension to request network sharing, such as when connection problems occur. Your container app needs to be in the foreground before calling this method. App requests: Your container app can call askToShare() to set the appRequestedSharing flag, indicating it wants your extension to present sharing UI. Your container app needs to be in the foreground before calling this method. important: When people choose to “Automatically Share” networks, the system adds new networks to future networks without needing additional calls to this method or further approval. note: WINetworkSharingError for various conditions: WINetworkSharingError.timeout: The person didn’t respond to the request. WINetworkSharingError.noAvailableNetworks: No shareable networks were available nearby. WINetworkSharingError.appNotInForeground: Called when newShareableNetworkAvailable is false and the container app isn’t in the foreground. WINetworkSharingError.accessoryNotAuthorized: The person hasn’t authorized network data sharing to the accessory. WINetworkSharingError.accessoryNotConnected: The accessory isn’t connected when making this request.

## See Also

### Displaying network selection

- [WINetworkSharingProvider.AccessoryScanRequest](wifiinfrastructure/winetworksharingprovider/accessoryscanrequest.md)
- [WINetworkSharingProvider.AccessoryScanResponse](wifiinfrastructure/winetworksharingprovider/accessoryscanresponse.md)
- [WINetworkSharingProvider.AccessoryScanResult](wifiinfrastructure/winetworksharingprovider/accessoryscanresult.md)
