# AdPlay Android SDK host-app integration prompt

Use this prompt with a coding assistant that can inspect and modify the target Android host-app project. Supply the AdPlay Android AAR and this prompt to that assistant.

```text
Act as an Android SDK integration engineer. Integrate the provided AdPlay Android SDK AAR into the existing host application. The host app remains the app; do not turn the SDK into an app or modify the SDK implementation. Use the supplied AAR, its integration guide, and the APIs actually present in the AAR as the source of truth. Do not invent APIs, server behavior, request fields, identifiers, placement semantics, or ad formats.

MANDATORY WORKFLOW

Stage 1 — Inspect before editing
1. Read repository instructions (AGENTS.md and equivalent), inspect git status, and preserve existing user changes.
2. Identify the app module, Gradle DSL, wrapper, AGP/Kotlin/JDK versions, compileSdk/targetSdk/minSdk, Java/Kotlin language, Views/Compose UI, navigation, application startup, lifecycle ownership, dependency injection, and existing network/consent/configuration patterns.
3. Inspect the supplied AAR and AdPlay integration documentation. Confirm the public API names and signatures, embedded manifest permissions, declared minimum SDK, bytecode/Kotlin metadata, and dependencies. Do not infer APIs from Unity.
4. The current documented SDK is version 1.0.0. Its verified consumer-build baseline is AGP 8.7.3, Gradle 8.9, Kotlin Gradle Plugin 2.0.21, JDK 21, compileSdk 35. Android runtime minSdk is 23. Treat other toolchain combinations as unverified unless this project supplies evidence.
5. The AAR is a plain local artifact, not a Maven publication with dependency metadata. The SDK module currently declares OkHttp 4.12.0 and kotlinx-serialization-json 1.7.3 as API dependencies, and kotlinx-coroutines-android 1.9.0 and play-services-ads-identifier 18.2.0 as implementation dependencies. Check the provided guide and host dependency graph for conflicts before adding them. Do not assume a raw AAR brings transitive dependencies.
6. Report the findings, likely host integration points, and blockers. Do not edit app files yet.

Stage 2 — Ask me and wait before placement-dependent edits
Ask a concise but complete set of questions and wait for my answers. At minimum ask:
A. Splash: which screen/app state, when in startup it appears, dismissal/timeout/navigation behavior, and what the app should do if no creative loads.
B. For EACH banner: target screen and exact UI container/position, which SDK banner slot (verify the actual enum; e.g. MainMenuSlot1 or MainMenuSlot2 only if present), Permanent or WeightBased selection, and no-ad fallback.
C. Whether to integrate popup, popup button, or interstitial sound. Offer only formats implemented by this AAR. Do not offer video/rewarded if unsupported.
D. How the host obtains the API token for development and release. Ask which local/CI/runtime configuration convention to use. Do not ask me to paste a production token into chat or commit it.
E. Whether the host has approved/disclosed Advertising ID and device ID collection, and whether any supported optional identifiers should be disabled. Never substitute a hardware identifier or enable public-IP lookup without explicit approval.
F. What HTTPS click destinations the host wants to allow. Inspect the SDK click-policy API; do not invent an allowlist.
If an answer is missing, leave that behavior unimplemented or use a documented safe default and report the blocker. Never choose ad placements, show modes, frequency, or interruption behavior for me.

Stage 3 — Propose minimal changes
After I answer, present a short plan naming the host files/modules you intend to edit and the selected placement/mode for each placement. Do not change the SDK source, credentials, signing, publishing, unrelated UI, navigation, backend, or other ad libraries.

Stage 4 — Integrate only approved behavior
Dependency:
- Follow the host's existing dependency convention. Prefer a compatible Maven source only if one is provided/configured for this AdPlay version; otherwise use the supplied local AAR.
- If using a local AAR, copy it into the agreed app/module libs directory, use implementation(files(...)), and add only missing compatible transitive dependencies after checking the current dependency graph. Keep dependency versions aligned and report conflicts.
- Preserve existing manifest entries. Verify merged permissions; add no extra permissions without evidence.

Token and configuration:
- The host constructs AdplayConfig(apiToken = tokenValue) and passes it to AdplaySdk(context, config, HostDataProviders()). Follow the exact API signature from the supplied artifact/docs.
- The token is not part of the AAR. Obtain it through the configuration source I approved. Use an untracked local Gradle property or CI environment variable for build-time configuration if selected; never commit a real token or print it.
- Any token used in a mobile app can be extracted. Do not describe local.properties, BuildConfig, resources, or environment injection as making a client token secret. Do not hard-code credentials. Do not send requests when only a placeholder/missing token is configured.
- Do not change the SDK endpoint or create backend routes. The documented API base is https://addata.ir/.

Initialization and error handling:
- Initialize/load at the startup point I approved, using lifecycle-aware async work and the SDK's documented retry/caching semantics. Do not add a second retry loop.
- Keep the host usable when requests fail, no ad exists, creative download fails, or decoding/display fails. Surface useful non-sensitive errors using the app's established UI/logging conventions.
- Do not block the main thread or log tokens, authorization headers, Advertising ID, device ID, public IP, or raw request bodies.

Placements and API usage:
- Use only public methods confirmed in the supplied AAR/docs: initialize()/loadAds(), showBanner(...), showSplash(...), showPopup(...), showPopupButton(...), showRelatedPopup(...), and playInterstitialSound(...) only if confirmed in the artifact.
- Use AdCreativeView or the actual view class from the AAR at the placements I approved. Keep loading separate from display and follow the host UI framework.
- For each banner use exactly my selected slot and CreativeShowType.Permanent or WeightBased. Do not call a method with a guessed slot or mode.
- For splash, follow the requested trigger and dismissal behavior without inventing impression duration or timing semantics.
- PopupButton must follow the SDK-provided related-popup callback; do not pretend its button is a normal click URL.
- Validate clicks through the SDK and host-approved HTTPS policy. Never bypass TLS or URL validation, accept arbitrary unsafe schemes, or add a certificate bypass.
- Handle MissingCreative, HTTP/network/decode/download errors and callback failure using actual SDK result types. Do not claim the SDK returns an ad if the server returns none.

Privacy, cache, and lifecycle:
- Read the SDK guide and actual defaults. Current SDK config defaults Advertising ID collection to enabled, Android device ID collection to disabled, and public-IP lookup to disabled. Do not silently change them. Ask me about consent/disclosure and apply only my approved settings.
- Do not use hardware identifiers or send the AdPlay Authorization token to an IP lookup or asset host.
- Document that creative metadata and images are persisted in app-private no-backup storage, images are URL-keyed and bounded (default 50 MiB total/10 MiB each), successful refresh prunes stale images, and cached metadata/images may support offline display. Audio is session-memory based. Confirm these details against the supplied version before publishing them.
- Bind SDK views and async work to Activity/Fragment/Compose lifecycle. Call documented start/stop/dispose/close and audio release operations; avoid leaked Activity references and duplicate initialization.
- Engagements are session-memory queued with at most three attempts total and are lost on process/app-session termination if unsent. Duplicate delivery can still happen after an ambiguous response. Do not add a durable queue, new event type, or idempotency field unless the supplied backend contract explicitly confirms it.

Stage 5 — Verify and report
- Build the relevant host variant if available. Do not run tests unless I explicitly ask, and do not publish/release anything.
- Inspect the final diff and verify no credentials were introduced.
- Report changed files, dependency additions, token source (never its value), each approved placement/slot/show mode, lifecycle/privacy decisions, build result, artifact path if relevant, and remaining blockers.
```

## Token reminder
The host app supplies the token at runtime/configuration when it constructs `AdplayConfig`. The AAR does not contain a project token. A token included in a client app can be extracted; protect it with server-side scope, authorization, rotation, and rate limits, and do not commit it.
