Vai alla navigazione

Inizia

Finestra del terminale
bun add @capgo/capacitor-admob
bunx cap sync
import { AdMob } from '@capgo/capacitor-admob';

Inizializza e avvia l'SDK AdMob.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();

Configura le impostazioni AdMob.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({
appMuted: false,
appVolume: 0.5
});

Configura le impostazioni della richiesta pubblicitaria.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configRequest({
maxAdContentRating: MaxAdContentRating.PG,
tagForChildDirectedTreatment: true,
testDeviceIds: ['test-device-id']
});

Crea un nuovo istante pubblicitario.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({
adUnitId: 'ca-app-pub-3940256099942544/1033173712'
});

Controlla se un annuncio è caricato e pronto per essere mostrato.

import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });
if (isLoaded) {
await AdMob.adShow({ id: 1 });
}

Carica un annuncio.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adLoad({ id: 1 });

Mostra un annuncio caricato.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adShow({ id: 1 });

Nascondi un annuncio attualmente visualizzato.

import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adHide({ id: 1 });

Ottieni lo stato di autorizzazione di tracciamento corrente (solo per iOS).

import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();
if (status === TrackingAuthorizationStatus.notDetermined) {
await AdMob.requestTrackingAuthorization();
}

Richiedi l'autorizzazione di tracciamento all'utente (solo per iOS).

import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.requestTrackingAuthorization();
console.log('User tracking status:', status);

Opzioni di configurazione per AdMob.

export type AdMobConfig = {
/** Whether the app should be muted */
appMuted?: boolean;
/** The app volume (0.0 to 1.0) */
appVolume?: number;
};

Configurazione per le richieste pubblicitarie.

export type RequestConfig = {
/** Maximum ad content rating */
maxAdContentRating?: MaxAdContentRating;
/** Whether to use the same app key */
sameAppKey?: boolean;
/** Tag for child-directed treatment (true, false, or null for unspecified) */
tagForChildDirectedTreatment?: boolean | null;
/** Tag for under age of consent (true, false, or null for unspecified) */
tagForUnderAgeOfConsent?: boolean | null;
/** Array of test device IDs */
testDeviceIds?: string[];
};

Opzioni base per gli annunci mobili.

export type MobileAdOptions = {
/** The ad unit ID from AdMob */
adUnitId: string;
};

Stato di autorizzazione di tracciamento per l'app di trasparenza dell'applicazione iOS.

export enum TrackingAuthorizationStatus {
/** User has not yet received an authorization request */
notDetermined = 0,
/** User restricted, device is unable to provide authorization */
restricted = 1,
/** User denied authorization */
denied = 2,
/** User authorized access */
authorized = 3,
}

Enum del massimo rating del contenuto pubblicitario utilizzato per limitare gli annunci in base al rating del contenuto.

export enum MaxAdContentRating {
/** General Audiences */
G = 'G',
/** Mature Audiences */
MA = 'MA',
/** Parental Guidance */
PG = 'PG',
/** Teen */
T = 'T',
/** Unspecified rating */
UNSPECIFIED = '',
}

Questa pagina è generata dal plugin e può essere aggiornata quando le informazioni pubbliche __CAPGO_KEEP_0__ vengono aggiornate upstream. src/definitions.ts. Re-run the sync when the public API changes upstream.