Getting Started
Copiez une commande de configuration avec les étapes d'installation et la guide markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-admob`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/admob/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installer
Section intitulée « Installer »You pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA à l'aide de la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsEnsuite, utilisez la prompt suivante :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-admob` plugin in my project.Si vous préférez la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :
bun add @capgo/capacitor-admobbunx cap syncImporter
Section intitulée « Importer »import { AdMob } from '@capgo/capacitor-admob';API Vue d'ensemble
Section intitulée “API Aperçu”Initialiser et démarrer le SDK AdMob.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();configure
Section intitulée “configurer”Configurer les paramètres AdMob.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});configRequest
Section intitulée “configurerDemande”Configurer les paramètres de demande publicitaire.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});Créer une nouvelle instance de publicité.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({ adUnitId: 'ca-app-pub-3940256099942544/1033173712'});adIsLoaded
Section intitulée “adIsLoaded”Vérifiez si une publicité est chargée et prête à être affichée.
import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });if (isLoaded) { await AdMob.adShow({ id: 1 });}Charger une publicité.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adLoad({ id: 1 });Afficher une publicité chargée.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adShow({ id: 1 });Cacher une publicité affichée actuellement.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adHide({ id: 1 });trackingAuthorizationStatus
Section intitulée “trackingAuthorizationStatus”Obtenez l'état actuel de l'autorisation de suivi (disponible uniquement sur iOS).
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();if (status === TrackingAuthorizationStatus.notDetermined) { await AdMob.requestTrackingAuthorization();}requestTrackingAuthorization
Section intitulée “requestTrackingAuthorization”Demander l'autorisation de suivi à l'utilisateur (disponible uniquement sur iOS).
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.requestTrackingAuthorization();console.log('User tracking status:', status);Référence de type
Section intitulée “Type Reference”AdMobConfig
Section intitulée “AdMobConfig”Options de configuration pour AdMob.
export type AdMobConfig = { /** Whether the app should be muted */ appMuted?: boolean; /** The app volume (0.0 to 1.0) */ appVolume?: number;};RequestConfig
Section intitulée « RequestConfig »Configuration des requêtes publicitaires.
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[];};MobileAdOptions
Section intitulée « MobileAdOptions »Options de base pour les publicités mobiles.
export type MobileAdOptions = { /** The ad unit ID from AdMob */ adUnitId: string;};TrackingAuthorizationStatus
Section intitulée « TrackingAuthorizationStatus »État d'autorisation de suivi pour iOS App Tracking Transparency.
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,}MaxAdContentRating
Section intitulée « MaxAdContentRating »Énumération de la note maximale de contenu publicitaire utilisée pour restreindre les publicités en fonction de la note de contenu.
export enum MaxAdContentRating { /** General Audiences */ G = 'G', /** Mature Audiences */ MA = 'MA', /** Parental Guidance */ PG = 'PG', /** Teen */ T = 'T', /** Unspecified rating */ UNSPECIFIED = '',}Source Of Truth
Section intitulée « Source Of Truth »Cette page est générée à partir du plugin’s src/definitions.tsRe-run the sync when the public API changes upstream.
Continuez de Getting Started
Section intitulée « Continuez de Getting Started »Si vous utilisez Getting Started pour planifier le tableau de bord et les opérations API, connectez-le avec Utilisez @capgo/capacitor-admob pour la capacité native dans Utilisez @capgo/capacitor-admob, API Overview pour les détails d'implémentation dans API Résumé, Introduction pour les détails d'implémentation dans Introduction, API Clés pour les détails d'implémentation dans API Clés, et Appareils pour les détails d'implémentation dans Appareils.