はじめに
このプラグインのインストール手順とフルマークダウンガイドを含むセットアップコマンドをコピーしてください。
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.
インストール
「インストール」のセクションbun add @capgo/capacitor-admobbunx cap syncインポート
「インポート」セクションimport { AdMob } from '@capgo/capacitor-admob';API オーバービュー
「API オーバービュー」セクションstart
「start」セクションSDK を初期化して起動する
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();configure
「configure」セクションAdMob設定を構成する
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});configRequest
configRequestセクション広告リクエスト設定を構成します。
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});adCreate
adCreateセクション新しい広告インスタンスを作成します。
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({ adUnitId: 'ca-app-pub-3940256099942544/1033173712'});adIsLoaded
広告が読み込まれているかどうかを確認します。クリップボードにコピー
import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });if (isLoaded) { await AdMob.adShow({ id: 1 });}adLoad
クリップボードにコピーadIsLoadedセクション
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
「trackingAuthorizationStatus」セクション現在のトラッキング承認状態を取得します (iOS 限定)。
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();if (status === TrackingAuthorizationStatus.notDetermined) { await AdMob.requestTrackingAuthorization();}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
リクエストの設定広告リクエストの設定
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
モバイル広告のオプションモバイル広告の基本オプション
export type MobileAdOptions = { /** The ad unit ID from AdMob */ adUnitId: string;};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」最大広告コンテンツレーティングのenumを使用して、コンテンツレーティングに基づいて広告を制限します。
export enum MaxAdContentRating { /** General Audiences */ G = 'G', /** Mature Audiences */ MA = 'MA', /** Parental Guidance */ PG = 'PG', /** Teen */ T = 'T', /** Unspecified rating */ UNSPECIFIED = '',}ソースオブトゥルス
セクション「ソースオブトゥルス」このページはプラグインのソースから生成されています。 . upstreamのpublic __CAPGO_KEEP_0__が変更された場合に再度syncを実行してください。 src/definitions.ts. Re-run the sync when the public API changes upstream.