<!--
{
  "availability" : [
    "iOS: 26.2.0 -",
    "iPadOS: 26.2.0 -",
    "macCatalyst: 26.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WiFiInfrastructure",
  "identifier" : "/documentation/WiFiInfrastructure/WINetworkSharingProvider/presentAskToShareUI(scanProvider:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Wi-Fi Infrastructure"
    ],
    "preciseIdentifier" : "s:18WiFiInfrastructure24WINetworkSharingProviderC19presentAskToShareUI04scanF0AA0dehiJ5StateOAC21AccessoryScanResponseVSgSo11ASAccessoryC_AC0nO7RequestVtYaYbcSg_tYaKF"
  },
  "title" : "presentAskToShareUI(scanProvider:)"
}
-->

# presentAskToShareUI(scanProvider:)

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

```
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

The [`WINetworkSharingAskToShareState`](/documentation/WiFiInfrastructure/WINetworkSharingAskToShareState), indicating a response from the person.

## 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()`](/documentation/WiFiInfrastructure/WINetworkSharingController/askToShare()) to set
  the [`appRequestedSharing`](/documentation/WiFiInfrastructure/WINetworkSharingProvider/NetworkEvent/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
> ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingProvider/NetworkEvent/networks`` without needing additional calls to this method or further approval.

> Throws: ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError`` for various conditions:
> 
> - ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError/timeout``: The person didn’t respond to the request.
> - ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError/noAvailableNetworks``: No shareable networks were available nearby.
> - ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError/appNotInForeground``: Called when ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingProvider/NetworkEvent/newShareableNetworkAvailable`` is false and the container app isn’t in the foreground.
> - ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError/accessoryNotAuthorized``: The person hasn’t authorized network data sharing to the accessory.
> - ``doc://com.apple.wifiinfrastructure/documentation/WiFiInfrastructure/WINetworkSharingError/accessoryNotConnected``: The accessory isn’t connected when making this request.

---

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)