Saltare al contenuto

Iniziare

GitHub

Puoi utilizzare la nostra configurazione assistita da AI per installare il plugin. Aggiungi le Capgo competenze al tuo strumento AI utilizzando il seguente comando:

Finestra del terminale
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Poi utilizza il seguente prompt:

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

Se preferisci la configurazione manuale, installa il plugin eseguendo i seguenti comandi e segui le istruzioni specifiche del tuo sistema operativo riportate di seguito:

Finestra del terminale
bun add @capgo/capacitor-age-range
bunx cap sync
import { AgeRange } from '@capgo/capacitor-age-range';

Richiedi la fascia di età dell'utente.

Sul dispositivo Android: consulta i segnali di età di Google Play API (nessun avviso all'utente). Sul dispositivo iOS: presenta il dialogo di dichiarazione di età del sistema (richiede 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);
}

Opzioni per la richiesta di età dell'utente.

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[];
}

Risultato della richiesta di intervallo di età.

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;
}

Stato di alto livello della richiesta di intervallo di età.

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';

Come è stato dichiarato o determinato l'intervallo di età.

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';

Valori di stato dell'utente Google Play specifici per Android.

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

Questa pagina è generata dal plugin’s src/definitions.tsRiepilogo. Riepilogare la sincronizzazione quando le informazioni pubbliche API cambiano in modo upstream.

Se stai utilizzando Inizia per pianificare il dashboard e le operazioni di API, connettilo con Usando @capgo/capacitor-age-range per la capacità nativa in Usando @capgo/capacitor-age-range, Panoramica API per i dettagli di implementazione in Panoramica API Introduzione per i dettagli di implementazione in Introduzione API Chiavi per i dettagli di implementazione in API Chiavi, e Dispositivi per i dettagli di implementazione in Dispositivi.