跳过内容

Page/area: Capgo marketing website. Role: Website copy sentence. Seen in: component Hero.astro. Message key `hero_subtitle_v2` (Hero Subtitle V2).

GitHub

您可以使用我们的AI辅助设置来安装插件。将Capgo技能添加到您的AI工具中,使用以下命令:

终端窗口
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

然后使用以下提示:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-age-range` plugin in my project.

如果您更喜欢手动设置,请运行以下命令安装插件,并按照以下平台特定的说明进行操作:

终端窗口
bun add @capgo/capacitor-age-range
bunx cap sync

导入

导入
import { AgeRange } from '@capgo/capacitor-age-range';

API 概述

API 概述

requestAgeRange

请求年龄范围

获取用户年龄范围

在 Android 上:使用 Google Play Age Signals API(无需用户提示)。 在 iOS 上:显示系统 DeclaredAgeRange dialog(要求 iOS 26.2+)。

import { AgeRange } from '@capgo/capacitor-age-range';
const result = await AgeRange.requestAgeRange({ ageGates: [13, 16, 18] });
if (result.status === 'SHARING') {
console.log('Age range:', result.ageLower, '-', result.ageUpper);
}

类型参考

类型参考

RequestAgeRangeOptions

请求年龄范围选项

年龄范围请求选项

export interface RequestAgeRangeOptions {
/**
* Age thresholds for the request.
*
* On iOS: these are passed to `requestAgeRange(ageGates:)` as the
* age boundaries presented in the system dialog. Common values: [13, 16, 18].
*
* On Android: this parameter is ignored (Play Age Signals returns
* predefined ranges: 0-12, 13-15, 16-17, 18+).
*
* @default [13, 16, 18]
* @since 8.0.0
*/
ageGates?: number[];
}

AgeRangeResult

AgeRangeResult

年龄范围请求结果

export interface AgeRangeResult {
/**
* The outcome status of the age range request.
*
* @since 8.0.0
*/
status: AgeRangeStatus;
/**
* Inclusive lower bound of the user's age range.
*
* Present when age data is available.
*
* @since 8.0.0
*/
ageLower?: number;
/**
* Inclusive upper bound of the user's age range.
*
* May be absent if the user is in the highest age bracket (e.g. 18+).
*
* @since 8.0.0
*/
ageUpper?: number;
/**
* How the age was declared/determined.
*
* On iOS: 'SELF_DECLARED' or 'GUARDIAN_DECLARED'.
* On Android: 'SUPERVISED' (guardian-managed) or 'VERIFIED' (Google-verified 18+).
*
* @since 8.0.0
*/
declarationSource?: DeclarationSource;
/**
* Android-only. The user's Google Play verification status.
*
* @since 8.0.0
*/
androidUserStatus?: AndroidUserStatus;
/**
* Android-only. Effective date for the most recent guardian-approved change.
*
* @since 8.0.0
*/
mostRecentApprovalDate?: string;
/**
* Android-only. Install identifier for supervised installs in Google Play.
*
* @since 8.0.0
*/
installId?: string;
}

AgeRangeStatus

AgeRangeStatus

年龄范围请求的顶级状态。

export type AgeRangeStatus =
/**
* The user shared their age range (iOS) or age signals are available (Android).
*/
| 'SHARING'
/**
* The user declined to share their age range.
*/
| 'DECLINED_SHARING'
/**
* The age range API is not available on this device/OS version.
*/
| 'NOT_AVAILABLE'
/**
* An error occurred while requesting the age range.
*/
| 'ERROR';

DeclarationSource

数据来源声明

年龄范围是如何被声明或确定的。

export type DeclarationSource =
/** The user self-declared their age (iOS). */
| 'SELF_DECLARED'
/** A guardian declared the user's age (iOS Family Sharing or Android supervised). */
| 'GUARDIAN_DECLARED'
/** Google has verified the user is 18+ (Android only). */
| 'VERIFIED'
/** Source is unknown or not provided by the platform. */
| 'UNKNOWN';

AndroidUserStatus

Android用户状态

Android特有的Google Play用户状态值。

export type AndroidUserStatus =
| 'VERIFIED'
| 'SUPERVISED'
| 'SUPERVISED_APPROVAL_PENDING'
| 'SUPERVISED_APPROVAL_DENIED'
| 'UNKNOWN'
| 'EMPTY';

真实来源

真实数据来源

本页面是由插件的 src/definitions.ts.重新同步时,公共API上游发生变化。

继续从Getting Started

标题:继续从Getting Started

如果您正在使用 开始使用 来规划仪表板和API操作,连接它到 使用@capgo/capacitor-age-range 使用@capgo/capacitor-age-range API概述 API概述 简介 简介 API 键 为 API Keys 的实现细节 设备 为设备的实现细节