__CAPGO_KEEP_3__

はじめに

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

SDKを初期化してアドモブを開始します。

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

アドモブの設定を構成します。

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

configRequest

configRequest

広告リクエスト設定を構成します。

import { AdMob, MaxAdContentRating } 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

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

Loaded adを表示します。

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

adHide

adHide

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

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

trackingAuthorizationStatus

トラッキングの承認状態

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

import { AdMob, TrackingAuthorizationStatus } 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

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

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

コンテンツレーティングに基づいて広告を制限するための最大広告コンテンツレーティングのenum。

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がアップストリームで変更されたときに再度Syncを実行してください。

Capacitorプラグインを使用している場合 スタートガイド 計画ダッシュボードとAPIの運用を計画し、接続する @capgo/capacitor-admobを使用する @capgo/capacitor-admobのネイティブ機能を使用する APIの概要 APIの実装詳細 導入 __CAPGO_KEEP_0__のキー APIの実装詳細、 Capgoの実装詳細については、API キーに参照してください。 Devices __CAPGO_KEEP_0__の実装詳細