Erste Schritte
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses 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.
Installieren
Abschnitt mit dem Titel „Installation“Du kannst unser KI-gestütztes Setup nutzen, um das Plugin zu installieren. Füge deinem KI-Tool die Capgo Skills mit folgendem Befehl hinzu:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsNutze anschließend diesen Prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-admob` plugin in my project.Wenn du ein manuelles Setup bevorziehst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:
bun add @capgo/capacitor-admobnpx cap syncImportieren
Abschnitt mit dem Titel „Import“import { AdMob } from '@capgo/capacitor-admob';Quickstart
Abschnitt mit dem Titel „Quickstart“import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();Beispiel: Konfiguration
Abschnitt mit dem Titel „Beispiel: Konfiguration“import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});Beispiel: configRequest
Abschnitt mit dem Titel „Beispiel: configRequest“import { AdMob, MaxAdContentRating } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});Häufige Fehlerquellen
Abschnitt mit dem Titel „Häufige Fehlerquellen“- Listener: Handles entfernen, wenn Screens unmounten.
- Einmal initialisieren: Setup beim App-Bootstrap ausführen.
- Single Source of Truth: vertraue
src/definitions.tsim GitHub Repo.
API Übersicht
Abschnitt mit dem Titel „API Übersicht“Initialisiere und starte das AdMob SDK.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();AdMob-Einstellungen konfigurieren.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});configRequest
Abschnitt „configRequest“Konfiguriere die Einstellungen für Ad-Requests.
import { AdMob, MaxAdContentRating } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});adCreate
Abschnitt „adCreate“Erstelle eine neue Ad-Instanz.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({ adUnitId: 'ca-app-pub-3940256099942544/1033173712'});adIsLoaded
Abschnitt „adIsLoaded“Prüfe, ob eine Ad geladen und bereit zur Anzeige ist.
import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });if (isLoaded) { await AdMob.adShow({ id: 1 });}adLoad
Abschnitt „adLoad“Lade eine Ad.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adLoad({ id: 1 });adShow
Abschnitt „adShow“Eine geladene Anzeige anzeigen.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adShow({ id: 1 });adHide
Abschnitt „adHide“Eine aktuell angezeigte Anzeige ausblenden.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adHide({ id: 1 });trackingAuthorizationStatus
Abschnitt „trackingAuthorizationStatus“Den aktuellen Status der Tracking-Autorisierung abrufen (nur iOS).
import { AdMob, TrackingAuthorizationStatus } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();if (status === TrackingAuthorizationStatus.notDetermined) { await AdMob.requestTrackingAuthorization();}requestTrackingAuthorization
Abschnitt „requestTrackingAuthorization“Den Nutzer um Tracking-Autorisierung bitten (nur iOS).
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.requestTrackingAuthorization();console.log('User tracking status:', status);Typ-Referenz
Abschnitt mit dem Titel „Type Reference“AdMobConfig
Abschnitt „AdMobConfig“Konfigurationsoptionen für AdMob.
export type AdMobConfig = { /** Whether the app should be muted */ appMuted?: boolean; /** The app volume (0.0 to 1.0) */ appVolume?: number;};RequestConfig
Abschnitt „RequestConfig“Konfiguration für Ad-Requests.
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
Abschnitt „MobileAdOptions“Basis-Optionen für Mobile Ads.
export type MobileAdOptions = { /** The ad unit ID from AdMob */ adUnitId: string;};TrackingAuthorizationStatus
Abschnitt mit dem Titel „TrackingAuthorizationStatus“Status der Tracking-Autorisierung für 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
Abschnitt mit dem Titel „MaxAdContentRating“Enum für die maximale Werbeinhaltsbewertung zur Einschränkung von Anzeigen basierend auf der Inhaltsbewertung.
export enum MaxAdContentRating { /** General Audiences */ G = 'G', /** Mature Audiences */ MA = 'MA', /** Parental Guidance */ PG = 'PG', /** Teen */ T = 'T', /** Unspecified rating */ UNSPECIFIED = '',}Source of Truth
Abschnitt mit dem Titel „Source of Truth“Diese Seite wird aus dem Plugin- src/definitions.ts. Führe den Sync erneut aus, wenn sich der öffentliche API upstream ändert.
Weiter mit Getting Started
Abschnitt „Weiter mit Getting Started“Wenn Sie ... verwenden Erste Schritte Um Dashboard- und API-Operationen zu planen, verbinde es mit Verwendung von @capgo/capacitor-admob für die native Funktionalität bei der Nutzung von @capgo/capacitor-admob, API Übersicht für Details zur Implementierung in der Übersicht zu API, Einführung für das Implementierungsdetail in der Einleitung, API Keys für die Implementierungsdetails in den API Keys und Geräte für die Implementierungsdetails bei Devices.