# SkillPatch skill: google-mobile-ads-rewarded

This skill provides structured guidance for implementing Google Mobile Ads (GMA) SDK rewarded ads in Android and iOS mobile applications. It covers the full workflow including loading ads, registering event callbacks, adding opt-in UI elements, and showing ads. It explicitly excludes rewarded interstitial ads and references platform-specific guides for Android and iOS.

You (the agent) were given this URL and asked to use this skill. This is a **public** skill — no SkillPatch account, API key, or prior setup is required. Two ways to use it:

**1. Use it right now** — the skill's complete file tree (SKILL.md + all reference files) is inlined below; read `SKILL.md` first, then follow it, consulting the other files as it directs.

**2. Install the exact package onto disk** (recommended if you can run a shell — this reproduces the skill byte-for-byte, including any binary assets that can't be inlined):

```bash
mkdir -p .claude/skills/google-mobile-ads-rewarded
curl -sSL https://skillpatch.dev/install_skill/google-mobile-ads-rewarded | tar -xz -C .claude/skills/
```

(`.claude/skills/` is Claude Code's convention; use whatever directory your agent loads skills from.)


---

## Skill files (3)

- `SKILL.md`
- `references/android-rewarded.md`
- `references/ios-rewarded.md`


### `SKILL.md`

```markdown
---
name: google-mobile-ads-rewarded
description: Provides instructions for implementing, integrating, or configuring
  Google Mobile Ads (GMA) SDK rewarded ads in Android or iOS mobile
  applications. Use this skill when the task involves setting up rewarded
  ads. Don't use for "rewarded interstitial" ads.
metadata:
  version: 1.0.0
  category: GoogleAds
---
# Google Mobile Ads SDK - Rewarded Ads

Rewarded ads reward users with in-app items for interacting with full-screen
ads. Rewarded ads are served after a user explicitly opts in to view a rewarded
ad.

### Ad Placement Guidelines

**CRITICAL:** You MUST evaluate and apply the following Ad Placement Guidelines
before proceeding with any rewarded ad implementation.

*   **Determine Ad Placement**:
    *   [ ] **Identify the target file** where the ad should be placed. Ask if
        unsure.

## Workflow

1.  **Determine the user's platform**: Identify if the project is Android or
    iOS. If unclear, ask before proceeding.

2.  **Read the platform guide** for implementation details:
    -   Android: `references/android-rewarded.md`
    -   iOS: `references/ios-rewarded.md`

3.  **Follow these steps in order**:
    -   [ ] Load the ad
    -   [ ] Register for ad event callbacks
    -   [ ] Add an opt-in UI element
    -   [ ] Show the ad
    -   [ ] Verify the implementation
```


### `references/android-rewarded.md`

````markdown
# AI Integration Agent Instructions for Rewarded Ads

## Required Imports

Use the following imports to implement a rewarded ad:

```
import com.google.android.libraries.ads.mobile.sdk.common.AdRequest
import com.google.android.libraries.ads.mobile.sdk.common.AdLoadCallback
import com.google.android.libraries.ads.mobile.sdk.common.FullScreenContentError
import com.google.android.libraries.ads.mobile.sdk.common.LoadAdError
import com.google.android.libraries.ads.mobile.sdk.rewarded.OnUserEarnedRewardListener
import com.google.android.libraries.ads.mobile.sdk.rewarded.RewardedAd
import com.google.android.libraries.ads.mobile.sdk.rewarded.RewardedAdEventCallback
```

## Method Signatures

Use the following method signatures to implement rewarded ads:

The `AdRequest` object takes the ad unit ID:

```
AdRequest.Builder(adUnitId: String).build()
```

The method signature to load an ad from `RewardedAd`:

```
fun load(
    adRequest: AdRequest,
    adLoadCallback: AdLoadCallback<RewardedAd>
): Unit
```

The `AdLoadCallback` interface is defined as:

```
interface AdLoadCallback<T> {
    fun onAdLoaded(ad: T): Unit
    fun onAdFailedToLoad(adError: LoadAdError): Unit
}
```

## Gotchas

**UI Threading**: **MANDATORY**: Callbacks in GMA-Next Gen SDK are invoked on a
background thread. **ALL UI-RELATED OPERATIONS** (e.g., Toasts, View updates,
Fragment transactions) **MUST** be wrapped in `runOnUiThread {}` or
`Dispatchers.Main.launch {}` within GMA SDK callbacks. SKIPPING THIS STEP WILL
CAUSE THE APPLICATION TO CRASH.

## Rewarded ad workflow

1.  **Load the ad**

2.  **Register for ad event callbacks**
    -   [ ] Set the `adEventCallback` on the `RewardedAd` object.
        *   Drop the reference to the rewarded ad when the ad is dismissed
            or fails to show.

3.  **Add an opt-in UI element** to give users the choice to watch the rewarded
    ad in exchange for an in-app reward.

4.  **Show the ad**
    *   The `show()` method requires an `OnUserEarnedRewardListener`.

5.  **Verify the implementation**: Verify the build to ensure there are no
    compile errors:
    -   [ ] Run `gradle build -x test` to confirm a successful clean build.
        Resolve any GMA SDK related compile errors.

#### Troubleshooting

**ONLY** if you exhaust your internal knowledge and not able to complete the
workflow steps, read
https://developers.google.com/admob/android/next-gen/rewarded.md.txt and try
again.

````


### `references/ios-rewarded.md`

```markdown
# AI Integration Agent Instructions for Rewarded Ads

## Gotchas

Google Mobile Ads SDK uses `NS_SWIFT_NAME` macros to provide idiomatic Swift
names.

## Rewarded ad workflow

1.  **Load the ad**
    *   For Swift code, use `async/await` instead of a completion handler.

2.  **Register for ad event callbacks**
    -   [ ] Set the `fullScreenContentDelegate` on the `RewardedAd` object.
        *   Drop the reference to the rewarded ad when the ad is dismissed
            or fails to show.

3.  **Add an opt-in UI element** to give users the choice to watch the rewarded
    ad in exchange for an in-app reward.

4.  **Show the ad**
    *   **ViewController Parameter:** The `rootViewController` parameter in the
    `present(from:)` method is an optional parameter and can be set to `nil`.
    *   The `present(from:)` method requires a `UserDidEarnRewardHandler`
        object.

5.  **Verify the implementation**: Verify the build to ensure there are no
    compile errors:
    -   **If `xcodebuild` is available**: Run `xcodebuild` to programmatically
        verify that the iOS project compiles properly with the GMA SDK. Resolve
        any GMA-SDK related compile errors.
    -   **If `xcodebuild` is NOT available**: Output instructions directing the
        user to build the project in Xcode and manually verify there are no
        compile errors.

#### Troubleshooting

**ONLY** if you exhaust your internal knowledge and not able to complete the
workflow steps, read
https://developers.google.com/admob/ios/rewarded.md.txt and try again.

```
