Mulai
Salin prompt pengaturan dengan langkah instalasi dan panduan markdown lengkap untuk plugin ini.
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.
Pasang
Judul bagian “Pasang”bun add @capgo/capacitor-admobbunx cap syncimport { AdMob } from '@capgo/capacitor-admob';API Ringkasan
Bagian berjudul “API Ringkasan”Inisialisasi dan mulai SDK AdMob.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.start();configure
Bagian berjudul “Konfigurasi”Konfigurasi pengaturan AdMob.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configure({ appMuted: false, appVolume: 0.5});configRequest
Bagian berjudul “configRequest”Konfigurasi pengaturan permintaan iklan.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.configRequest({ maxAdContentRating: MaxAdContentRating.PG, tagForChildDirectedTreatment: true, testDeviceIds: ['test-device-id']});adCreate
Bagian berjudul “adCreate”Buat instance iklan baru.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adCreate({ adUnitId: 'ca-app-pub-3940256099942544/1033173712'});adIsLoaded
Bagian berjudul “adIsLoaded”Periksa jika iklan telah dimuat dan siap ditampilkan.
import { AdMob } from '@capgo/capacitor-admob';
const isLoaded = await AdMob.adIsLoaded({ id: 1 });if (isLoaded) { await AdMob.adShow({ id: 1 });}adLoad
Bagian berjudul “adLoad”Muat iklan.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adLoad({ id: 1 });adShow
Bagian berjudul “adShow”Tampilkan iklan yang telah dimuat.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adShow({ id: 1 });adHide
Bagian berjudul “adHide”Sembunyikan iklan yang sedang ditampilkan.
import { AdMob } from '@capgo/capacitor-admob';
await AdMob.adHide({ id: 1 });trackingAuthorizationStatus
Bagian berjudul “trackingAuthorizationStatus”Dapatkan status otorisasi pelacakan saat ini (hanya iOS).
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.trackingAuthorizationStatus();if (status === TrackingAuthorizationStatus.notDetermined) { await AdMob.requestTrackingAuthorization();}requestTrackingAuthorization
Bagian berjudul “requestTrackingAuthorization”Minta otorisasi pelacakan dari pengguna (hanya iOS).
import { AdMob } from '@capgo/capacitor-admob';
const { status } = await AdMob.requestTrackingAuthorization();console.log('User tracking status:', status);Referensi Tipe
Bagian berjudul “Referensi Tipe”AdMobConfig
Bagian berjudul “Konfigurasi AdMob”Opsi konfigurasi untuk AdMob.
export type AdMobConfig = { /** Whether the app should be muted */ appMuted?: boolean; /** The app volume (0.0 to 1.0) */ appVolume?: number;};RequestConfig
Bagian berjudul “Konfigurasi Permintaan”Konfigurasi untuk permintaan iklan.
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
Bagian berjudul “Opsi Iklan Mobile”Opsi dasar untuk iklan mobile.
export type MobileAdOptions = { /** The ad unit ID from AdMob */ adUnitId: string;};TrackingAuthorizationStatus
Status Otorisasi PemantauanMengatur status otorisasi untuk Pemantauan Aplikasi iOS.
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
Status Rating Konten MaksimumEnum rating konten maksimum digunakan untuk membatasi iklan berdasarkan rating konten.
export enum MaxAdContentRating { /** General Audiences */ G = 'G', /** Mature Audiences */ MA = 'MA', /** Parental Guidance */ PG = 'PG', /** Teen */ T = 'T', /** Unspecified rating */ UNSPECIFIED = '',}Sumber Kebenaran
Halaman ini dihasilkan dari plugin’sRe-run sinkronisasi ketika publik __CAPGO_KEEP_0__ berubah di atas. src/definitions.ts. Re-run the sync when the public API changes upstream.