admanagekit-mcp-server 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/README.md +851 -0
- package/content/docs/AD_FREQUENCY_CONTROL.md +450 -0
- package/content/docs/AD_LOADING_STRATEGIES.md +369 -0
- package/content/docs/API_REFERENCE.md +734 -0
- package/content/docs/APP_PURCHASE_GUIDE.md +704 -0
- package/content/docs/BANNER_AD_IMPROVEMENTS.md +325 -0
- package/content/docs/COMPOSE_INTEGRATION.md +477 -0
- package/content/docs/CONFIGURATION_USAGE.md +168 -0
- package/content/docs/INTERSTITIAL_BUILDER_GUIDE.md +518 -0
- package/content/docs/JAVA_USAGE_GUIDE.md +785 -0
- package/content/docs/LOADING_STRATEGY_EXAMPLES.md +463 -0
- package/content/docs/NATIVE_AD_MANAGER_ENHANCEMENTS.md +347 -0
- package/content/docs/NATIVE_AD_PRELOADING.md +467 -0
- package/content/docs/NATIVE_TEMPLATE_VIEW.md +413 -0
- package/content/docs/app-open-ads.md +412 -0
- package/content/docs/interstitial-ads.md +269 -0
- package/content/docs/native-ads-caching.md +182 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.1.0.md +156 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.2.0.md +248 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.3.0.md +280 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.5.0.md +73 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.6.0.md +265 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.7.0.md +168 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.8.0.md +153 -0
- package/content/docs/release-notes/RELEASE_NOTES_v2.9.0.md +479 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.0.0.md +343 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.1.0.md +131 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.3.0.md +252 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.3.2.md +215 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.3.3.md +116 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.3.4.md +142 -0
- package/content/docs/release-notes/RELEASE_NOTES_v3.3.5.md +94 -0
- package/content/docs/rewarded-ads.md +623 -0
- package/content/wiki/Ad-Loading-Strategies.md +209 -0
- package/content/wiki/App-Open-Ads.md +189 -0
- package/content/wiki/Banner-Ads.md +133 -0
- package/content/wiki/Billing-Integration.md +69 -0
- package/content/wiki/Configuration.md +252 -0
- package/content/wiki/Consumable-Products.md +166 -0
- package/content/wiki/Home.md +144 -0
- package/content/wiki/Interstitial-Ads.md +313 -0
- package/content/wiki/Jetpack-Compose.md +270 -0
- package/content/wiki/NativeAdManager.md +220 -0
- package/content/wiki/Purchase-Categories.md +94 -0
- package/content/wiki/Rewarded-Ads.md +420 -0
- package/content/wiki/Subscription-Upgrades.md +278 -0
- package/content/wiki/Subscriptions.md +368 -0
- package/content/wiki/_Footer.md +3 -0
- package/content/wiki/_Sidebar.md +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +18 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/code-generation.d.ts +2 -0
- package/dist/tools/code-generation.js +264 -0
- package/dist/tools/code-generation.js.map +1 -0
- package/dist/tools/documentation.d.ts +2 -0
- package/dist/tools/documentation.js +202 -0
- package/dist/tools/documentation.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.js +83 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/doc-loader.d.ts +17 -0
- package/dist/utils/doc-loader.js +245 -0
- package/dist/utils/doc-loader.js.map +1 -0
- package/dist/utils/search.d.ts +2 -0
- package/dist/utils/search.js +62 -0
- package/dist/utils/search.js.map +1 -0
- package/dist/utils/templates.d.ts +60 -0
- package/dist/utils/templates.js +793 -0
- package/dist/utils/templates.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Interstitial Ads - AdManageKit v2.8.0
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
AdManageKit provides a complete interstitial ad stack with `AdManager` and the fluent `InterstitialAdBuilder`. Features include loading strategies, automatic retry, frequency controls, splash screen support, and Jetpack Compose utilities.
|
|
6
|
+
|
|
7
|
+
**Library Version**: v2.8.0
|
|
8
|
+
|
|
9
|
+
## What's New
|
|
10
|
+
|
|
11
|
+
### v2.8.0
|
|
12
|
+
- `forceShowInterstitial()` now respects global loading strategy
|
|
13
|
+
- New `forceShowInterstitialAlways()` for explicit force fetch
|
|
14
|
+
- Global `interstitialAutoReload` config with per-call override
|
|
15
|
+
- All AdManager methods use global auto-reload config as default
|
|
16
|
+
|
|
17
|
+
### v2.7.0
|
|
18
|
+
- Smart splash screen with `waitForLoading()` in InterstitialAdBuilder
|
|
19
|
+
- New `isLoading()` and `showOrWaitForAd()` methods
|
|
20
|
+
- Frequency controls: `everyNthTime`, `maxShows`, `minInterval`
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```groovy
|
|
25
|
+
dependencies {
|
|
26
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit:v2.8.0'
|
|
27
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-core:v2.8.0'
|
|
28
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-billing:v2.8.0'
|
|
29
|
+
// Optional - Jetpack Compose
|
|
30
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose:v2.8.0'
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
Set up in your `Application.onCreate()`:
|
|
37
|
+
|
|
38
|
+
```kotlin
|
|
39
|
+
class MyApp : Application() {
|
|
40
|
+
override fun onCreate() {
|
|
41
|
+
super.onCreate()
|
|
42
|
+
|
|
43
|
+
BillingConfig.setPurchaseProvider(BillingPurchaseProvider())
|
|
44
|
+
|
|
45
|
+
AdManageKitConfig.apply {
|
|
46
|
+
debugMode = BuildConfig.DEBUG
|
|
47
|
+
defaultInterstitialInterval = 20.seconds
|
|
48
|
+
autoRetryFailedAds = true
|
|
49
|
+
maxRetryAttempts = 3
|
|
50
|
+
|
|
51
|
+
// Loading strategy (v2.6.0+)
|
|
52
|
+
interstitialLoadingStrategy = AdLoadingStrategy.HYBRID
|
|
53
|
+
|
|
54
|
+
// Auto-reload after showing (v2.8.0+)
|
|
55
|
+
interstitialAutoReload = true // default: true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Option 1: Direct AdManager
|
|
62
|
+
|
|
63
|
+
### Basic Usage
|
|
64
|
+
|
|
65
|
+
```kotlin
|
|
66
|
+
private val adManager = AdManager.getInstance()
|
|
67
|
+
|
|
68
|
+
// Preload
|
|
69
|
+
fun preloadInterstitial(activity: Activity) {
|
|
70
|
+
adManager.loadInterstitialAd(activity, AD_UNIT_INTERSTITIAL)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Show
|
|
74
|
+
fun showInterstitial(activity: Activity) {
|
|
75
|
+
adManager.forceShowInterstitial(activity, object : AdManagerCallback() {
|
|
76
|
+
override fun onNextAction() {
|
|
77
|
+
navigateNext()
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Key Methods
|
|
84
|
+
|
|
85
|
+
| Method | Description |
|
|
86
|
+
|--------|-------------|
|
|
87
|
+
| `loadInterstitialAd(context, adUnitId)` | Preload and cache ad |
|
|
88
|
+
| `loadInterstitialAdForSplash(context, unit, timeout, callback)` | Splash-friendly with timeout |
|
|
89
|
+
| `forceShowInterstitial(activity, callback)` | Respects loading strategy (v2.8.0+) |
|
|
90
|
+
| `forceShowInterstitialAlways(activity, callback)` | Always force fetch (v2.8.0+) |
|
|
91
|
+
| `showInterstitialIfReady(activity, callback, reloadAd)` | Show only if cached |
|
|
92
|
+
| `showInterstitialAdByTime(activity, callback)` | Time-interval based |
|
|
93
|
+
| `showInterstitialAdByCount(activity, callback, maxCount)` | Count-limited |
|
|
94
|
+
| `showOrWaitForAd(activity, callback, timeout, showDialog)` | Smart splash (v2.7.0+) |
|
|
95
|
+
| `isLoading()` | Check if currently loading (v2.7.0+) |
|
|
96
|
+
| `isReady()` | Check if ad is cached |
|
|
97
|
+
|
|
98
|
+
### Loading Strategy Behavior (v2.8.0+)
|
|
99
|
+
|
|
100
|
+
`forceShowInterstitial()` now respects `AdManageKitConfig.interstitialLoadingStrategy`:
|
|
101
|
+
|
|
102
|
+
| Strategy | Behavior |
|
|
103
|
+
|----------|----------|
|
|
104
|
+
| ON_DEMAND | Always fetch fresh ad with dialog |
|
|
105
|
+
| ONLY_CACHE | Show cached if ready, skip otherwise |
|
|
106
|
+
| HYBRID | Show cached if ready, fetch fresh otherwise |
|
|
107
|
+
|
|
108
|
+
```kotlin
|
|
109
|
+
// Set strategy
|
|
110
|
+
AdManageKitConfig.interstitialLoadingStrategy = AdLoadingStrategy.HYBRID
|
|
111
|
+
|
|
112
|
+
// Now respects strategy
|
|
113
|
+
AdManager.getInstance().forceShowInterstitial(activity, callback)
|
|
114
|
+
|
|
115
|
+
// Always force fetch (bypasses strategy)
|
|
116
|
+
AdManager.getInstance().forceShowInterstitialAlways(activity, callback)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Splash Screen Example
|
|
120
|
+
|
|
121
|
+
```kotlin
|
|
122
|
+
// In Application.onCreate() - start loading early
|
|
123
|
+
AdManager.getInstance().loadInterstitialAd(this, adUnitId)
|
|
124
|
+
|
|
125
|
+
// In SplashActivity - smart wait
|
|
126
|
+
AdManager.getInstance().showOrWaitForAd(
|
|
127
|
+
activity = this,
|
|
128
|
+
callback = object : AdManagerCallback() {
|
|
129
|
+
override fun onNextAction() { startMainActivity() }
|
|
130
|
+
},
|
|
131
|
+
timeoutMillis = 5000,
|
|
132
|
+
showDialogIfLoading = true
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Option 2: InterstitialAdBuilder
|
|
137
|
+
|
|
138
|
+
The builder provides a fluent API with frequency controls and loading strategies.
|
|
139
|
+
|
|
140
|
+
### Basic Usage
|
|
141
|
+
|
|
142
|
+
```kotlin
|
|
143
|
+
InterstitialAdBuilder.with(this)
|
|
144
|
+
.adUnit("ca-app-pub-xxx/yyy")
|
|
145
|
+
.show { navigateNext() }
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Full Configuration
|
|
149
|
+
|
|
150
|
+
```kotlin
|
|
151
|
+
InterstitialAdBuilder.with(this)
|
|
152
|
+
.adUnit("primary-unit")
|
|
153
|
+
.fallback("backup-unit")
|
|
154
|
+
.loadingStrategy(AdLoadingStrategy.HYBRID)
|
|
155
|
+
.everyNthTime(3) // Show every 3rd call
|
|
156
|
+
.maxShows(10) // Maximum 10 shows total
|
|
157
|
+
.minIntervalSeconds(30) // Minimum 30 seconds between
|
|
158
|
+
.timeout(5000) // 5 second timeout
|
|
159
|
+
.autoReload(true) // Auto-reload after showing
|
|
160
|
+
.onAdShown { /* analytics */ }
|
|
161
|
+
.onAdDismissed { /* cleanup */ }
|
|
162
|
+
.onFailed { error -> /* handle */ }
|
|
163
|
+
.show { navigateNext() }
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Smart Splash Screen (v2.7.0+)
|
|
167
|
+
|
|
168
|
+
```kotlin
|
|
169
|
+
// In Application.onCreate()
|
|
170
|
+
AdManager.getInstance().loadInterstitialAd(this, adUnitId)
|
|
171
|
+
|
|
172
|
+
// In SplashActivity
|
|
173
|
+
InterstitialAdBuilder.with(this)
|
|
174
|
+
.adUnit(adUnitId)
|
|
175
|
+
.waitForLoading() // Smart: shows cached, waits for loading, or force fetches
|
|
176
|
+
.timeout(5000) // 5 second max wait
|
|
177
|
+
.show { startMainActivity() }
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Behavior:**
|
|
181
|
+
| Ad State | Action |
|
|
182
|
+
|----------|--------|
|
|
183
|
+
| READY | Shows immediately |
|
|
184
|
+
| LOADING | Waits with timeout, shows when ready |
|
|
185
|
+
| NOT STARTED | Force fetches with dialog |
|
|
186
|
+
|
|
187
|
+
### Frequency Controls
|
|
188
|
+
|
|
189
|
+
```kotlin
|
|
190
|
+
// Show every 3rd time
|
|
191
|
+
.everyNthTime(3)
|
|
192
|
+
|
|
193
|
+
// Maximum 5 shows total
|
|
194
|
+
.maxShows(5)
|
|
195
|
+
|
|
196
|
+
// Minimum 30 seconds between shows
|
|
197
|
+
.minIntervalSeconds(30)
|
|
198
|
+
|
|
199
|
+
// Force show (bypass interval)
|
|
200
|
+
.force()
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Auto-Reload Configuration (v2.8.0+)
|
|
204
|
+
|
|
205
|
+
```kotlin
|
|
206
|
+
// Global config
|
|
207
|
+
AdManageKitConfig.interstitialAutoReload = false // Disable globally
|
|
208
|
+
|
|
209
|
+
// Per-call override
|
|
210
|
+
InterstitialAdBuilder.with(activity)
|
|
211
|
+
.adUnit(adUnitId)
|
|
212
|
+
.autoReload(true) // Override global
|
|
213
|
+
.show { next() }
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Priority:** Builder `.autoReload()` > `AdManageKitConfig.interstitialAutoReload`
|
|
217
|
+
|
|
218
|
+
## Option 3: Jetpack Compose
|
|
219
|
+
|
|
220
|
+
```kotlin
|
|
221
|
+
@Composable
|
|
222
|
+
fun ContentWithInterstitial() {
|
|
223
|
+
val showAd = rememberInterstitialAd(
|
|
224
|
+
adUnitId = stringResource(R.string.interstitial_feed),
|
|
225
|
+
preloadAd = true,
|
|
226
|
+
onAdShown = { /* analytics */ },
|
|
227
|
+
onAdDismissed = { navigateNext() },
|
|
228
|
+
onAdFailedToLoad = { /* handle */ }
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
Button(onClick = showAd) {
|
|
232
|
+
Text("Show Ad")
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Compose Helpers
|
|
238
|
+
|
|
239
|
+
| Helper | Purpose |
|
|
240
|
+
|--------|---------|
|
|
241
|
+
| `rememberInterstitialAd(...)` | Returns lambda to show ad |
|
|
242
|
+
| `InterstitialAdEffect(...)` | Declarative effect with TIME/COUNT/FORCE modes |
|
|
243
|
+
| `rememberInterstitialAdState(...)` | Mutable state with `isLoaded`, `loadAd()`, `showAd()` |
|
|
244
|
+
|
|
245
|
+
## API Reference
|
|
246
|
+
|
|
247
|
+
### AdManager Methods
|
|
248
|
+
|
|
249
|
+
| Method | Description |
|
|
250
|
+
|--------|-------------|
|
|
251
|
+
| `loadInterstitialAd(context, adUnitId)` | Preload ad |
|
|
252
|
+
| `loadInterstitialAdForSplash(...)` | Splash with timeout |
|
|
253
|
+
| `forceShowInterstitial(activity, callback)` | Respects strategy |
|
|
254
|
+
| `forceShowInterstitialAlways(activity, callback)` | Always force fetch |
|
|
255
|
+
| `showInterstitialIfReady(activity, callback, reloadAd)` | Show cached |
|
|
256
|
+
| `showInterstitialAdByTime(activity, callback)` | Time-based |
|
|
257
|
+
| `showInterstitialAdByCount(activity, callback, max)` | Count-based |
|
|
258
|
+
| `showOrWaitForAd(...)` | Smart splash |
|
|
259
|
+
| `isLoading()` | Check loading state |
|
|
260
|
+
| `isReady()` | Check if cached |
|
|
261
|
+
| `preloadAd(context, adUnitId)` | Background preload |
|
|
262
|
+
|
|
263
|
+
### InterstitialAdBuilder Methods
|
|
264
|
+
|
|
265
|
+
| Method | Description |
|
|
266
|
+
|--------|-------------|
|
|
267
|
+
| `.adUnit(id)` | Set primary ad unit (required) |
|
|
268
|
+
| `.fallback(id)` / `.fallbacks(...)` | Fallback units |
|
|
269
|
+
| `.loadingStrategy(strategy)` | Override strategy |
|
|
270
|
+
| `.everyNthTime(n)` | Show every Nth call |
|
|
271
|
+
| `.maxShows(count)` | Limit total shows |
|
|
272
|
+
| `.minInterval(ms)` / `.minIntervalSeconds(s)` | Minimum interval |
|
|
273
|
+
| `.timeout(ms)` / `.timeoutSeconds(s)` | Load timeout |
|
|
274
|
+
| `.autoReload(boolean)` | Override auto-reload |
|
|
275
|
+
| `.waitForLoading()` | Smart splash behavior |
|
|
276
|
+
| `.force()` | Bypass interval |
|
|
277
|
+
| `.onAdShown {}` | Shown callback |
|
|
278
|
+
| `.onAdDismissed {}` | Dismissed callback |
|
|
279
|
+
| `.onFailed {}` | Failure callback |
|
|
280
|
+
| `.show {}` | Execute and show |
|
|
281
|
+
| `.preload()` | Preload without showing |
|
|
282
|
+
|
|
283
|
+
### AdManageKitConfig Settings
|
|
284
|
+
|
|
285
|
+
| Setting | Description | Default |
|
|
286
|
+
|---------|-------------|---------|
|
|
287
|
+
| `interstitialLoadingStrategy` | Loading strategy | HYBRID |
|
|
288
|
+
| `interstitialAutoReload` | Auto-reload after showing | true |
|
|
289
|
+
| `defaultInterstitialInterval` | Time between ads | 15 seconds |
|
|
290
|
+
| `defaultAdTimeout` | Load timeout | 15 seconds |
|
|
291
|
+
| `autoRetryFailedAds` | Enable retry | true |
|
|
292
|
+
| `maxRetryAttempts` | Max retries | 3 |
|
|
293
|
+
|
|
294
|
+
## Best Practices
|
|
295
|
+
|
|
296
|
+
1. **Configure once** in `Application.onCreate()`
|
|
297
|
+
2. **Use HYBRID strategy** for balanced UX and coverage
|
|
298
|
+
3. **Preload** on previous screen for better fill rate
|
|
299
|
+
4. **Use frequency controls** to protect UX
|
|
300
|
+
5. **Wire billing** to skip ads for premium users
|
|
301
|
+
6. **Enable debug mode** during development
|
|
302
|
+
|
|
303
|
+
## Troubleshooting
|
|
304
|
+
|
|
305
|
+
- **Ad Not Loading**: Check adUnitId, network, and AdMob config
|
|
306
|
+
- **Ad Not Showing**: Verify `isReady()` and purchase status
|
|
307
|
+
- **Strategy Not Working**: Ensure v2.8.0+ and check `interstitialLoadingStrategy`
|
|
308
|
+
|
|
309
|
+
## References
|
|
310
|
+
|
|
311
|
+
- [AdMob Interstitial Docs](https://developers.google.com/admob/android/interstitial)
|
|
312
|
+
- [Firebase Analytics Docs](https://firebase.google.com/docs/analytics)
|
|
313
|
+
- [GitHub Repository](https://github.com/i2hammad/AdManageKit)
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Jetpack Compose Integration - AdManageKit v2.8.0
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
AdManageKit provides first-class Jetpack Compose support with composable functions for all ad types, state management helpers, and programmatic native ad loading.
|
|
6
|
+
|
|
7
|
+
**Library Version**: v2.8.0
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```groovy
|
|
12
|
+
dependencies {
|
|
13
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit:v2.8.0'
|
|
14
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-core:v2.8.0'
|
|
15
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose:v2.8.0'
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Banner Ads
|
|
20
|
+
|
|
21
|
+
```kotlin
|
|
22
|
+
@Composable
|
|
23
|
+
fun MyScreen() {
|
|
24
|
+
BannerAdCompose(
|
|
25
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
26
|
+
modifier = Modifier.fillMaxWidth()
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Native Ads
|
|
32
|
+
|
|
33
|
+
### NativeTemplateCompose (v2.6.0+)
|
|
34
|
+
|
|
35
|
+
```kotlin
|
|
36
|
+
@Composable
|
|
37
|
+
fun MyScreen() {
|
|
38
|
+
NativeTemplateCompose(
|
|
39
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
40
|
+
template = NativeAdTemplate.MATERIAL3,
|
|
41
|
+
loadingStrategy = AdLoadingStrategy.HYBRID,
|
|
42
|
+
modifier = Modifier.fillMaxWidth()
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Traditional Native Composables
|
|
48
|
+
|
|
49
|
+
```kotlin
|
|
50
|
+
@Composable
|
|
51
|
+
fun MyScreen() {
|
|
52
|
+
// Small format
|
|
53
|
+
NativeBannerSmallCompose(
|
|
54
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
55
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
// Medium format
|
|
59
|
+
NativeBannerMediumCompose(
|
|
60
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
61
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
// Large format
|
|
65
|
+
NativeLargeCompose(
|
|
66
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
67
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Programmatic Native Ads
|
|
73
|
+
|
|
74
|
+
Build your own native ad UI:
|
|
75
|
+
|
|
76
|
+
```kotlin
|
|
77
|
+
@Composable
|
|
78
|
+
fun MyScreen() {
|
|
79
|
+
ProgrammaticNativeBannerMediumCompose(
|
|
80
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
81
|
+
onAdLoaded = { /* success */ },
|
|
82
|
+
onAdFailed = { /* error */ }
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Interstitial Ads
|
|
88
|
+
|
|
89
|
+
### rememberInterstitialAd
|
|
90
|
+
|
|
91
|
+
```kotlin
|
|
92
|
+
@Composable
|
|
93
|
+
fun MyScreen() {
|
|
94
|
+
val showInterstitial = rememberInterstitialAd(
|
|
95
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
96
|
+
preloadAd = true,
|
|
97
|
+
onAdShown = { analytics.log("ad_shown") },
|
|
98
|
+
onAdDismissed = { navigateNext() },
|
|
99
|
+
onAdFailedToLoad = { error -> Log.e("Ad", error) }
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
Button(onClick = { showInterstitial() }) {
|
|
103
|
+
Text("Show Ad")
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### InterstitialAdEffect
|
|
109
|
+
|
|
110
|
+
Declarative effect-based approach:
|
|
111
|
+
|
|
112
|
+
```kotlin
|
|
113
|
+
@Composable
|
|
114
|
+
fun MyScreen() {
|
|
115
|
+
var showAd by remember { mutableStateOf(false) }
|
|
116
|
+
|
|
117
|
+
InterstitialAdEffect(
|
|
118
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
119
|
+
showMode = InterstitialShowMode.TIME,
|
|
120
|
+
maxDisplayCount = 5,
|
|
121
|
+
onAdDismissed = { navigateNext() }
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
Button(onClick = { showAd = true }) {
|
|
125
|
+
Text("Continue")
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### rememberInterstitialAdState
|
|
131
|
+
|
|
132
|
+
Full state control:
|
|
133
|
+
|
|
134
|
+
```kotlin
|
|
135
|
+
@Composable
|
|
136
|
+
fun MyScreen() {
|
|
137
|
+
val adState = rememberInterstitialAdState("ca-app-pub-xxx/yyy")
|
|
138
|
+
|
|
139
|
+
// Load manually
|
|
140
|
+
LaunchedEffect(Unit) {
|
|
141
|
+
adState.loadAd()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Check state
|
|
145
|
+
if (adState.isLoaded) {
|
|
146
|
+
Button(onClick = { adState.showAd() }) {
|
|
147
|
+
Text("Show Ad")
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Conditional Ads
|
|
154
|
+
|
|
155
|
+
Hide ads for premium users:
|
|
156
|
+
|
|
157
|
+
```kotlin
|
|
158
|
+
@Composable
|
|
159
|
+
fun MyScreen() {
|
|
160
|
+
ConditionalAd {
|
|
161
|
+
// Only shown if user hasn't purchased
|
|
162
|
+
NativeBannerMediumCompose(adUnitId = "ca-app-pub-xxx/yyy")
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Cache Warming
|
|
168
|
+
|
|
169
|
+
Preload ads on screen entry:
|
|
170
|
+
|
|
171
|
+
```kotlin
|
|
172
|
+
@Composable
|
|
173
|
+
fun MyScreen() {
|
|
174
|
+
CacheWarmingEffect(
|
|
175
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
176
|
+
adType = AdType.INTERSTITIAL
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
// Your screen content
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## API Reference
|
|
184
|
+
|
|
185
|
+
### Composable Functions
|
|
186
|
+
|
|
187
|
+
| Function | Description |
|
|
188
|
+
|----------|-------------|
|
|
189
|
+
| `BannerAdCompose` | Banner ad composable |
|
|
190
|
+
| `NativeTemplateCompose` | Native with templates |
|
|
191
|
+
| `NativeBannerSmallCompose` | Small native ad |
|
|
192
|
+
| `NativeBannerMediumCompose` | Medium native ad |
|
|
193
|
+
| `NativeLargeCompose` | Large native ad |
|
|
194
|
+
| `ProgrammaticNativeBannerMediumCompose` | Programmatic native |
|
|
195
|
+
| `ConditionalAd` | Conditional wrapper |
|
|
196
|
+
|
|
197
|
+
### State Helpers
|
|
198
|
+
|
|
199
|
+
| Function | Description |
|
|
200
|
+
|----------|-------------|
|
|
201
|
+
| `rememberInterstitialAd` | Returns show lambda |
|
|
202
|
+
| `rememberInterstitialAdState` | Returns full state |
|
|
203
|
+
| `InterstitialAdEffect` | Declarative effect |
|
|
204
|
+
| `CacheWarmingEffect` | Preload effect |
|
|
205
|
+
| `AdManageKitInitEffect` | Initialization effect |
|
|
206
|
+
|
|
207
|
+
### InterstitialShowMode
|
|
208
|
+
|
|
209
|
+
| Mode | Description |
|
|
210
|
+
|------|-------------|
|
|
211
|
+
| `TIME` | Time-based trigger |
|
|
212
|
+
| `COUNT` | Count-based trigger |
|
|
213
|
+
| `FORCE` | Always show |
|
|
214
|
+
|
|
215
|
+
## Best Practices
|
|
216
|
+
|
|
217
|
+
1. **Preload early** - Use `preloadAd = true` or `CacheWarmingEffect`
|
|
218
|
+
2. **Use ConditionalAd** - Respect premium users
|
|
219
|
+
3. **Handle callbacks** - Always handle `onAdDismissed`
|
|
220
|
+
4. **Choose right helper** - `rememberInterstitialAd` for simple cases
|
|
221
|
+
5. **Match template** - Use appropriate native template
|
|
222
|
+
|
|
223
|
+
## Complete Example
|
|
224
|
+
|
|
225
|
+
```kotlin
|
|
226
|
+
@Composable
|
|
227
|
+
fun ContentScreen() {
|
|
228
|
+
val showInterstitial = rememberInterstitialAd(
|
|
229
|
+
adUnitId = stringResource(R.string.interstitial_ad),
|
|
230
|
+
preloadAd = true,
|
|
231
|
+
onAdDismissed = { /* navigate */ }
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
Column {
|
|
235
|
+
// Banner at top
|
|
236
|
+
ConditionalAd {
|
|
237
|
+
BannerAdCompose(adUnitId = stringResource(R.string.banner_ad))
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Content
|
|
241
|
+
LazyColumn {
|
|
242
|
+
items(articles) { article ->
|
|
243
|
+
ArticleItem(article)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Native ad in feed
|
|
247
|
+
item {
|
|
248
|
+
ConditionalAd {
|
|
249
|
+
NativeTemplateCompose(
|
|
250
|
+
adUnitId = stringResource(R.string.native_ad),
|
|
251
|
+
template = NativeAdTemplate.LIST_ITEM
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Action button
|
|
258
|
+
Button(onClick = { showInterstitial() }) {
|
|
259
|
+
Text("Next Article")
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## References
|
|
266
|
+
|
|
267
|
+
- [GitHub Repository](https://github.com/i2hammad/AdManageKit)
|
|
268
|
+
- [[Interstitial Ads]]
|
|
269
|
+
- [[Native Ads|NativeAdManager]]
|
|
270
|
+
- [[Banner Ads]]
|