メインコンテンツにジャンプ

Getting Started

GitHub

Capgo の AI-Assisted Setup を使用してプラグインをインストールできます。AI ツールに Capgo スキルを追加するには、以下のコマンドを実行してください。

ターミナル ウィンドウ
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次のコマンドを使用してください。

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

Manual Setup を使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。

ターミナル画面
bun add @capgo/capacitor-admob
bunx cap sync
import { AdMob } from '@capgo/capacitor-admob';

Capacitor SDKを初期化して開始します。

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

Capacitor __CAPGO_KEEP_0__の設定を構成します。

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

広告要求設定を構成します。

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

新しい広告インスタンスを作成します。

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

広告が読み込まれているかどうかを確認します。

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

広告を読み込みます。

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

ロードされた広告を表示します。

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

現在表示されている広告を非表示にします。

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

現在のトラッキング承認状態を取得します (iOS 限定)。

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

ユーザーからトラッキング承認を要求します (iOS 限定)。

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

タイプ リファレンス

タイプ リファレンス

AdMobConfig

AdMobConfig

AdMobの設定オプション

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

広告リクエストの設定

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

モバイル アドの基本設定

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

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

広告のコンテンツレーティングを制限するために使用される最大広告コンテンツレーティングの列挙型

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

ソース オブ トゥルース

このページはプラグインの

パブリック __CAPGO_KEEP_0__ がアップストリームで変更されたときに再度 Sync を実行してください。 src/definitions.ts. Re-run the sync when the public API changes upstream.

「続けて「Getting Started」から」セクション

Source Of Truth

Capgoを使用している場合 Getting Started ダッシュボードとAPIの作業を計画するには Capgoを使用して@capgo/capacitor-admob Capgoのネイティブ機能のための@capgo/capacitor-admob APIの概要 APIの実装の詳細 導入 __CAPGO_KEEP_0__のAPIキー APIの実装の詳細 for the implementation detail in API Keys, and __CAPGO_KEEP_0__ デバイスの実装詳細について。