Saltar al contenido

Inicio rápido

Configuración

Instalación
Ventana de terminal
bun add @capgo/capacitor-admob
bunx cap sync
import { AdMob } from '@capgo/capacitor-admob';

Iniciar y arrancar el anuncio de SDK AdMob.

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

Configurar ajustes de AdMob.

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

Configura los ajustes de solicitud de anuncios.

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

Crear una nueva instancia de anuncio.

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

Verificar si un anuncio está cargado y listo para ser mostrado.

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

Cargar un anuncio.

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

Mostrar un anuncio cargado.

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

Ocultar un anuncio actualmente mostrado.

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

Obtener el estado actual de autorización de seguimiento (solo iOS).

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

Solicitar autorización de seguimiento al usuario (solo iOS).

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

Opciones de configuración para AdMob.

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

Configuración para solicitudes de anuncios.

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

Opciones base para anuncios móviles.

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

Estado de autorización de seguimiento para la transparencia de aplicaciones de seguimiento de 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,
}

Valor máximo de clasificación de contenido publicitario enum utilizado para restringir anuncios según la clasificación de contenido.

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

Esta página se genera a partir del plugin’s. src/definitions.tsRe-ejecutar la sincronización cuando los cambios públicos API cambien en la fuente.