# ShowConfirmationDialogAsync

> Displays a dialog that asks the user for consent to download asset packs that require user confirmation or WiFi connection.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Android](/engine/6000.7/script-reference/unityengine/android.md)
* **Assembly:** UnityEngine.AndroidJNIModule

## ShowConfirmationDialogAsync(Action\<AndroidAssetPackConfirmationDialogResult>)

Displays a dialog that asks the user for consent to download asset packs that require user confirmation or WiFi connection.

```csharp
public static void ShowConfirmationDialogAsync(Action<AndroidAssetPackConfirmationDialogResult> callback)
```

### Parameters

**** (\[Action\<AndroidAssetPackConfirmationDialogResult>]\(https\://learn.microsoft.com/dotnet/api/system.action)): The callback method to get the user's response. Must have an AndroidAssetPackConfirmationDialogResult parameter containing the user's response. The application invokes this callback once after the user submits their decision.

### Remarks

If the device isn't connected to WiFi, large Android asset pack downloads pause until a WiFi connection is available. In this case, the asset pack has the [AndroidAssetPackStatus.WaitingForWifi](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/waitingforwifi.md) status. Asset packs can also have [AndroidAssetPackStatus.RequiresUserConfirmation](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/requiresuserconfirmation.md) status if the current app version was not installed through the Google Play Store. In both situations, the asset packs require user consent to download. To get this consent, call `ShowConfirmationDialogAsync` to give the user the option to download your application's asset packs using mobile data or to update the app if a valid version isn't installed. This method directly wraps Google's PlayCore plugin API. If the PlayCore plugin is missing, calling this method throws an InvalidOperationException exception.

Additional Resources: [AndroidAssetPackConfirmationDialogResult](/engine/6000.7/script-reference/unityengine/android/androidassetpackconfirmationdialogresult.md), [AndroidAssetPacks.CancelAssetPackDownload](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/cancelassetpackdownload.md), [AndroidAssetPacks.DownloadAssetPackAsync](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/downloadassetpackasync.md), [AndroidAssetPacks.GetAssetPackStateAsync](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/getassetpackstateasync.md), [AndroidAssetPackStatus.RequiresUserConfirmation](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/requiresuserconfirmation.md), [AndroidAssetPackStatus.WaitingForWifi](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/waitingforwifi.md)

### Examples

```csharp
using UnityEngine;
using UnityEngine.Android;

public class ShowConfirmationDialogAsyncCallbackExample : MonoBehaviour
{
    // Call this when an asset pack download is waiting for user confirmation
    // (for example, when the status is WaitingForWifi or RequiresUserConfirmation).    
    public void ShowDialog()
    {
        AndroidAssetPacks.ShowConfirmationDialogAsync(OnDialogResult);
    }

    void OnDialogResult(AndroidAssetPackConfirmationDialogResult result)
    {
        if (result.consentGiven)
        {
            Debug.Log("User gave consent. Downloads will resume.");
        }
        else
        {
            Debug.Log("User denied consent. Downloads will remain paused.");
        }
    }
}
```

## ShowConfirmationDialogAsync()

Displays a dialog that asks the user for consent to download asset packs that require user confirmation or WiFi connection.

```csharp
public static ConfirmationDialogAsyncOperation ShowConfirmationDialogAsync()
```

### Returns

| Type                                                                                                                        | Description                                                                                                                                                 |
| --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ConfirmationDialogAsyncOperation](/engine/6000.7/script-reference/unityengine/android/confirmationdialogasyncoperation.md) | Returns an object that represents the request operation. If you yield this object inside a coroutine, the coroutine pauses until the operation is complete. |

### Remarks

If the device isn't connected to WiFi, large Android asset pack downloads pause until a WiFi connection is available. In this case, the asset pack has the [AndroidAssetPackStatus.WaitingForWifi](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/waitingforwifi.md) status. Asset packs can also have [AndroidAssetPackStatus.RequiresUserConfirmation](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/requiresuserconfirmation.md) status if the current app version was not installed through the Google Play Store. In both situations, the asset packs require user consent to download. To get this consent, call `ShowConfirmationDialogAsync` to give the user the option to download your application's asset packs using mobile data or to update the app if a valid version isn't installed. This method directly wraps Google's PlayCore plugin API. If the PlayCore plugin is missing, calling this method throws an InvalidOperationException exception.

Additional Resources: [ConfirmationDialogAsyncOperation](/engine/6000.7/script-reference/unityengine/android/confirmationdialogasyncoperation.md), [AndroidAssetPacks.CancelAssetPackDownload](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/cancelassetpackdownload.md), [AndroidAssetPacks.DownloadAssetPackAsync](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/downloadassetpackasync.md), [AndroidAssetPacks.GetAssetPackStateAsync](/engine/6000.7/script-reference/unityengine/android/androidassetpacks/getassetpackstateasync.md), [AndroidAssetPackStatus.RequiresUserConfirmation](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/requiresuserconfirmation.md), [AndroidAssetPackStatus.WaitingForWifi](/engine/6000.7/script-reference/unityengine/android/androidassetpackstatus/waitingforwifi.md)

### Examples

```csharp
using System.Collections;
using UnityEngine;
using UnityEngine.Android;

public class ShowConfirmationDialogAsyncExample : MonoBehaviour
{
    bool isShowingDialog = false;

    void Start()
    {
        var assetPackNames = new string[] { "MyAssetPack" };

        // Start the download with a callback to monitor status changes.
        AndroidAssetPacks.DownloadAssetPackAsync(
            assetPackNames,
            info =>
            {
                Debug.Log($"{info.name}: {info.status}");

                if (!isShowingDialog &&
                    (info.status == AndroidAssetPackStatus.WaitingForWifi ||
                     info.status == AndroidAssetPackStatus.RequiresUserConfirmation))
                {
                    // Show a dialog asking the user for consent.
                    isShowingDialog = true;
                    StartCoroutine(HandleConfirmationDialog());
                }
            }
        );
    }

    IEnumerator HandleConfirmationDialog()
    {
        var dialogOperation = AndroidAssetPacks.ShowConfirmationDialogAsync();

        // Yield until the user responds.
        yield return dialogOperation;

        if (dialogOperation.result.consentGiven)
        {
            Debug.Log("User gave consent. Downloads will resume.");
        }
        else
        {
            Debug.Log("User denied consent. Downloads remain paused.");
        }

        isShowingDialog = false;
    }
}
```
