User.GetAgeVerificationStatusAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves a value indicating whether and how the current user's age has been verified.
public:
virtual IAsyncOperation<UserAgeVerificationStatus> ^ GetAgeVerificationStatusAsync() = GetAgeVerificationStatusAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<UserAgeVerificationStatus> GetAgeVerificationStatusAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<UserAgeVerificationStatus> GetAgeVerificationStatusAsync();
function getAgeVerificationStatusAsync()
Public Function GetAgeVerificationStatusAsync () As IAsyncOperation(Of UserAgeVerificationStatus)
Returns
An asynchronous operation that returns a UserAgeVerificationStatus value for the current user.
- Attributes
Windows requirements
| Requirements | Description |
|---|---|
| Device family |
Windows 11, version 24H2 (introduced in 10.0.26100.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced in v19.0)
|
| App capabilities |
userAccountInformation
|
Examples
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.System.h>
using namespace winrt;
using namespace winrt::Windows::System;
int wmain()
{
init_apartment();
User user = User::GetDefault();
UserAgeVerificationStatus status =
user.GetAgeVerificationStatusAsync().get();
switch (status)
{
case UserAgeVerificationStatus::Verified:
// The user's age is verified.
break;
case UserAgeVerificationStatus::Unverified:
// The user's age isn't verified.
break;
case UserAgeVerificationStatus::OptedOut:
// The user opted out.
break;
case UserAgeVerificationStatus::TemporarilyUnavailable:
// Retry later or use the app's fallback experience.
break;
case UserAgeVerificationStatus::NotApplicable:
// Use the app's fallback experience.
break;
}
}
User user = User.GetDefault();
UserAgeVerificationStatus status =
await user.GetAgeVerificationStatusAsync();
switch (status)
{
case UserAgeVerificationStatus.Verified:
break;
case UserAgeVerificationStatus.Unverified:
break;
case UserAgeVerificationStatus.OptedOut:
break;
case UserAgeVerificationStatus.TemporarilyUnavailable:
break;
case UserAgeVerificationStatus.NotApplicable:
break;
}
Remarks
The following table describes the possible return values.
| Value | Name | Meaning |
|---|---|---|
| 0 | NotApplicable |
Age verification doesn't apply, no verification signal is available, or the feature is unavailable or disabled. |
| 1 | TemporarilyUnavailable |
The verification status can't currently be determined. The app can retry later. |
| 2 | Unverified |
The user's age hasn't been verified. |
| 3 | OptedOut |
The user has opted out of age verification. |
| 4 | Verified |
The user's age has been verified. |
NotApplicable and TemporarilyUnavailable don't establish that the user is either verified or unverified. Handle them as separate states.
- Call this method on the User object for the user running the current process. Use User.GetDefault to obtain that user directly.
- The app package must declare the
userAccountInformationcapability. A caller without access, or a caller using aUserobject for a different user, can receiveE_ACCESSDENIED. - In C++/WinRT, call
.get()from a suitable non-UI thread or useco_awaitfrom a coroutine.
Administrative policy
Administrators can disable the Digital Safety age APIs or configure a default verification status through Group Policy or MDM. When the APIs are disabled, this method returns NotApplicable. When a default status is configured, this method returns the configured Verified or Unverified value.