Zum Inhalt springen

Getting Started

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie den Capgo-Fähigkeiten Ihrer AI-Werkzeug mit dem folgenden Befehl hinzu:

Terminal-Fenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Verwenden Sie dann den folgenden Befehl:

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

Wenn Sie die manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und folgen Sie den unten angegebenen Plattform-spezifischen Anweisungen:

Terminal-Fenster
bun add @capgo/capacitor-admob
bunx cap sync
import { AdMob } from '@capgo/capacitor-admob';

SDK AdMob initialisieren und starten.

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

Konfigurieren Sie die Einstellungen für Anzeigenanfragen.

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

Erstellen Sie eine neue Anzeigeninstanz.

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

Überprüfen Sie, ob eine Anzeige geladen und bereit zum Anzeigen ist.

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

Laden Sie eine Anzeige.

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

Zeige geladenen Werbung.

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

Verstecke eine derzeit angezeigte Werbung.

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

Ermittle den aktuellen Zustand der Trackingberechtigung (nur iOS).

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

Bereite die Trackingberechtigung des Benutzers (nur iOS) vor.

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

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

Konfiguration für Anforderungen von Werbung.

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

Grundlegende Optionen für mobile Anzeigen.

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

Zustimmungsstatus für Tracking bei 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,
}

Enum zur maximalen Anzeigeninhaltsbewertung, die zur Einschränkung von Anzeigen auf der Grundlage der Inhaltsbewertung verwendet wird.

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

Diese Seite wird aus dem Plugin generiert. src/definitions.tsRe-run the sync wenn die öffentliche API upstream ändert.

Wenn Sie Getting Started um das Dashboard und API-Operationen zu planen und es mit Mit @capgo/capacitor-admob zu verbinden für die native Fähigkeit in Mit @capgo/capacitor-admob, API-Übersicht für die Implementierungsdetails in API-Übersicht, Einführung für die Implementierungsdetails in Einführung, API-Schlüssel für die Implementierungsdetails in API-Schlüssel, und Geräte für die Implementierungsdetails in Geräte.