Full SDK Guide

Detailed AMOS examples by integration path.

Use this page after the quick setup page. Pick the app stack and serving model, then follow the detailed steps and copy the matching examples.

Choose an integration

Detailed setup examples

Back to quick setup

Dependency

Add the AdMob wrapper artifact

dependencies {
    implementation("com.yuktinai:amos-sdk-admob:1.0.16")
}

Groups

Define local AdMob groups

object PublisherAdMobConfigProvider {
    fun build() = AdMobConfig(
        interstitialGroups = mapOf(
            AdMobConfig.DEFAULT_GROUP_REF to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/111"),
                preloadOnInit = true
            ),
            "interstitial_level_end" to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/112"),
                allowFallbackToDefault = true
            )
        ),
        rewardedGroups = mapOf(
            "rewarded_bonus_claim" to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/222"),
                preloadOnInit = true,
                allowFallbackToDefault = true
            )
        ),
        bannerGroups = mapOf(
            "banner_content" to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/333")
            )
        ),
        nativeGroups = mapOf(
            "native_feed_card" to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/444")
            )
        ),
        appOpenGroups = mapOf(
            "app_open_cold_start" to AdMobGroupConfig(
                unitIds = listOf("ca-app-pub-xxx/555"),
                preloadOnInit = true
            )
        )
    )
}

Initialize

Initialize AMOS and the wrapper

AmosAdMob.configure(PublisherAdMobConfigProvider.build())

Monetization.init(
    context = applicationContext,
    apiKey = "YOUR_API_KEY",
    appId = "YOUR_APP_ID",
    userId = "publisher-user-123"
) {
    AmosAdMob.initialize(this)
}

Show Ads

Use group refs from app screens

AmosAdMob.showRewarded(
    activity = this,
    groupRef = "rewarded_bonus_claim",
    onRewardEarned = { grantCreditToUser() },
    onFailed = { error -> Log.w("AMOS", "Rewarded failed: $error") }
)

AmosAdMob.showInterstitial(
    activity = this,
    groupRef = "interstitial_level_end"
)

AmosAdMob.createBannerView(
    context = this,
    groupRef = "banner_content",
    container = bannerContainer
)

Dependency

Add core SDK and provider SDK

dependencies {
    implementation("com.yuktinai:amos-sdk:1.0.16")
    implementation("com.google.android.gms:play-services-ads:25.4.0")
}

Session

Initialize core AMOS

Monetization.init(
    context = applicationContext,
    apiKey = "YOUR_API_KEY",
    appId = "YOUR_APP_ID",
    userId = "publisher-user-123"
) {
    Monetization.trackEventIfAllowed("first_open")
}

Manual Load

Load interstitial in your app layer

val request = Monetization.preloadAdMobInterstitial("interstitial_level_end")
if (request != null) {
    InterstitialAd.load(
        context,
        request.unitId,
        AdRequest.Builder().build(),
        object : InterstitialAdLoadCallback() {
            override fun onAdLoaded(ad: InterstitialAd) {
                Monetization.markAdMobInterstitialLoaded(request.groupRef, ad)
            }

            override fun onAdFailedToLoad(error: LoadAdError) {
                Monetization.markAdMobInterstitialLoadFailed(request.groupRef)
            }
        }
    )
}

Telemetry

Track metrics and show outcomes

Monetization.trackMetricsIfAllowed(
    mapOf(
        "platform" to "android",
        "country" to "US",
        "device_model" to Build.MODEL
    )
)

Monetization.recordAdMobInterstitialShown("interstitial_level_end")
Monetization.recordAdMobRewardedShown("rewarded_bonus_claim")

Install

Add the React Native AdMob wrapper

npm install @amos-sdk/react-native-admob@1.0.19

Provider

Configure AMOS at app root

import { AmosProvider } from '@amos-sdk/react-native-admob';

const amosConfig = {
  apiKey: 'YOUR_API_KEY',
  appId: 'YOUR_APP_ID',
  userId: 'publisher-user-123',
  bootstrap: {
    firstOpenEvent: 'first_open',
    metrics: ['platform', 'country', 'install_source', 'device_model'],
    installSourceFallback: 'other',
  },
  admob: {
    interstitialGroups: {
      default: { unitIds: ['ca-app-pub-xxx/111'] },
    },
    rewardedGroups: {
      default: { unitIds: ['ca-app-pub-xxx/222'], preloadOnInit: true },
    },
    bannerGroups: {
      default: { unitIds: ['ca-app-pub-xxx/333'] },
    },
  },
};

export function App() {
  return (
    <AmosProvider config={amosConfig}>
      <RootNavigator />
    </AmosProvider>
  );
}

Usage

Use wrapper methods directly

import { AmosBannerAd, useAmos } from '@amos-sdk/react-native-admob';

function RewardScreen() {
  const amos = useAmos();

  async function onRewardTap() {
    const rewarded = await amos.showRewarded('default');
    if (rewarded) {
      await amos.trackEvent('rewarded_ad_complete');
      grantCreditToUser();
    }
  }

  return <AmosBannerAd groupRef="default" />;
}

Install

Add core React Native package

npm install @amos-sdk/react-native@2.0.12

Provider

Initialize without provider-specific ad serving

import { AmosProvider } from '@amos-sdk/react-native';

const amosConfig = {
  apiKey: 'YOUR_API_KEY',
  appId: 'YOUR_APP_ID',
  userId: 'publisher-user-123',
  bootstrap: {
    firstOpenEvent: 'first_open',
    metrics: ['platform', 'country', 'install_source', 'device_model'],
  },
};

export function App() {
  return (
    <AmosProvider config={amosConfig}>
      <RootNavigator />
    </AmosProvider>
  );
}

Signals

Track configured events and metrics

const amos = useAmos();

await amos.trackEvent('image_selection');
await amos.trackEvent('ai_feature_completed');

await amos.trackMetric('platform', 'android');
await amos.trackMetric('device_model', 'sm_s908b');

Install

Add Flutter core and AdMob

dependencies:
  amos_flutter: ^1.0.0
  amos_flutter_admob: ^1.0.0

Android manifest

Add the publisher AdMob app ID

<application ...>
  <meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy" />
</application>

Initialize

Start core before the provider

final state = await AmosClient.instance.initialize(
  const AmosConfiguration(
    apiKey: String.fromEnvironment('AMOS_API_KEY'),
    appId: 'YOUR_APP_ID',
    externalUserId: 'stable-user-reference',
  ),
);

await AmosAdMob.instance.initialize();

Ads

Load, show, and render safely

final ads = state.decision.ads;

if (state.decision.provider == 'admob' && ads.interstitialEnabled) {
  final load = await AmosAdMob.instance.preloadInterstitial();
  if (load.loaded) await AmosAdMob.instance.showInterstitial();
}

if (ads.rewardedEnabled) {
  await AmosAdMob.instance.preloadRewarded();
  final result = await AmosAdMob.instance.showRewarded();
  if (result.rewardEarned) grantReward();
}

// Widget tree:
return ads.bannerEnabled
    ? const AmosBannerAd()
    : const SizedBox.shrink();

Install

Add Flutter core

dependencies:
  amos_flutter: ^1.0.0

Session

Initialize AMOS

final state = await AmosClient.instance.initialize(
  const AmosConfiguration(
    apiKey: String.fromEnvironment('AMOS_API_KEY'),
    appId: 'YOUR_APP_ID',
    externalUserId: 'stable-user-reference',
  ),
);

Signals and policy

Track outcomes and consume decisions

await AmosClient.instance.trackEvent('purchase_completed');
await AmosClient.instance.trackMetric('purchase_value', 9.99);

final paywall = await AmosClient.instance
    .getPaywallDecision('editor_export');
if (paywall.shouldShow) {
  showYourPaywall();
  await AmosClient.instance.recordPaywallShown('editor_export');
}

final config = await AmosClient.instance.getRemoteConfig();