Skip to content

feat: add reward ad show API#20

Merged
2sem merged 3 commits into
mainfrom
feat/reward-ad-api
Jul 15, 2026
Merged

feat: add reward ad show API#20
2sem merged 3 commits into
mainfrom
feat/reward-ad-api

Conversation

@2sem

@2sem 2sem commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Goal and success criteria

  • Support developer-facing rewarded ad flow via prepare(rewardUnit:) and show(rewardUnit:).
  • Return GoogleMobileAds.RewardedAd? directly from the reward-specific show callback.
  • Expose reward amount and type through rewardedAd.adReward.
  • Preserve existing generic show(unit:) compatibility.

User flow

flowchart TD
    A[App calls prepare rewardUnit] --> B[GADManager loads RewardedAd]
    B -->|Success| C[Cache rewarded ad]
    B -->|Failure| F[Completion false]
    C --> D[App calls show rewardUnit]
    D --> E[Present rewarded ad]
    E --> G{User earned reward?}
    G -->|Yes| H[Callback RewardedAd + rewarded=true]
    G -->|No| I[Callback rewarded=false]
    H --> J[Read adReward amount and type]
    J --> K[Auto reprepare]
    I --> K
Loading

Workstreams and deliverables

  • Library API: add show(rewardUnit:...) returning RewardedAd? and improve load failure handling.
  • Lifecycle: preserve test mode, force, and presenting view controller while waiting for a reward ad to load.
  • Lifecycle: retain rewarded ad reprepare behavior and test label configuration.
  • Docs: update README rewarded ad example.

Dependencies and critical path

  • Depends on the existing GADManager rewarded ad lifecycle and GoogleMobileAds RewardedAd API.
  • Critical path: load rewarded ad -> present -> earn reward callback -> dismissal completion -> reprepare.

Risks and mitigations

  • Backward compatibility: existing prepare(rewardUnit:isTesting:) calls remain valid because the new parameter has a default.
  • Hanging callbacks: load failure and missing ad ID clear and invoke pending completions with false.
  • Deferred presentation: test mode and supplied presentation options are retained across loading.
  • Reward metadata: callers receive RewardedAd and can read adReward.amount and adReward.type.

Verification

  • git diff --check origin/main passes.
  • swift build --triple arm64-apple-ios12.0-simulator --sdk "$(xcrun --sdk iphonesimulator --show-sdk-path)" passes.
  • No automated test target exists in the package.

Release checklist

  • Validate rewarded presentation in a host app.
  • Confirm RewardedAd.adReward returns the expected amount and type.
  • Confirm rewarded is true only after reward is earned.
  • Monitor ad load and presentation failures after release.
  • Roll back by reverting this PR if reward integration regresses.

@github-actions

Copy link
Copy Markdown

🤖 Hi @2sem, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions

Copy link
Copy Markdown

🤖 I'm sorry @2sem, but I was unable to process your request. Please see the logs for more details.

@2sem 2sem merged commit d80e179 into main Jul 15, 2026
@2sem 2sem deleted the feat/reward-ad-api branch July 15, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant