Getting Started
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアップコマンドをコピーしてください。
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.
インストール
セクション:インストールAI-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、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 セットアップを使用する場合は、次のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の説明を参照してください。
bun add @capgo/capacitor-admobbunx cap syncインポート
「インポート」のセクションimport { AdMob } from '@capgo/capacitor-admob';Initialize and start the AdMob SDK.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();configure
Section titled “configure”Configure AdMob settings.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});configRequest
Section titled “configRequest”Configure ad request settings.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});adCreate
Section titled “adCreate”Create a new ad instance.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({ adUnitId: 'ca-app-pub-3940256099942544/1033173712'});adIsLoaded
「adIsLoaded」セクション広告が読み込まれているかどうかを確認します。
import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });if (isLoaded) { await AdMob.adShow({ id: 1 });}adLoad
「adLoad」セクション広告を読み込みます。
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adLoad({ id: 1 });adShow
「adShow」セクション読み込まれた広告を表示します。
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adShow({ id: 1 });adHide
「adHide」セクション現在表示されている広告を非表示にします。
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adHide({ id: 1 });trackingAuthorizationStatus
トラッキング認証状態のセクション現在のトラッキング認証状態を取得 (iOS 限定)
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();if (status === TrackingAuthorizationStatus.notDetermined) { await AdMob.requestTrackingAuthorization();}requestTrackingAuthorization
トラッキング認証の要求のセクションユーザーからトラッキング認証を要求 (iOS 限定)
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.requestTrackingAuthorization();console.log('User tracking status:', status);型の参照
型の参照AdMobConfig
AdMobの設定AdMobの設定オプション
export type AdMobConfig = { /** Whether the app should be muted */ appMuted?: boolean; /** The app volume (0.0 to 1.0) */ appVolume?: number;};RequestConfig
「RequestConfig」セクション広告リクエストの設定
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
「MobileAdOptions」セクションモバイル広告の基本設定
export type MobileAdOptions = { /** The ad unit ID from AdMob */ adUnitId: string;};TrackingAuthorizationStatus
「TrackingAuthorizationStatus」セクション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
「MaxAdContentRating」セクション広告の最大コンテンツレーティングの制限
export enum MaxAdContentRating { /** General Audiences */ G = 'G', /** Mature Audiences */ MA = 'MA', /** Parental Guidance */ PG = 'PG', /** Teen */ T = 'T', /** Unspecified rating */ UNSPECIFIED = '',}真実の源
「真実の源」セクションこのページはプラグインの src/definitions.tsパブリック API がアップストリームで変更された場合に再度同期を実行してください。
Getting Started から続けてください
「Getting Started から続けてください」セクションCapacitor を使用している場合 Getting Started ダッシュボードと API の作業を計画するには、Capacitor を Capacitor の @capgo/capacitor-admob Capacitor の @capgo/capacitor-admob Capacitor の API オーバービュー 実装詳細については API の概要を参照してください。 概要 実装詳細については Introduction を参照してください。 API のキー 実装詳細については API のキー、 デバイス 実装詳細については Devices を参照してください。