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,477 @@
|
|
|
1
|
+
# Jetpack Compose Integration Guide
|
|
2
|
+
|
|
3
|
+
**Module:** `ad-manage-kit-compose`
|
|
4
|
+
|
|
5
|
+
AdManageKit provides native Jetpack Compose components for all ad types with full feature parity to the View-based components.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```groovy
|
|
10
|
+
implementation 'com.github.i2hammad.AdManageKit:ad-manage-kit-compose:v2.6.0'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Available Components
|
|
14
|
+
|
|
15
|
+
| Component | Description |
|
|
16
|
+
|-----------|-------------|
|
|
17
|
+
| `NativeTemplateCompose` | Unified native ad with 28 templates (NEW in 2.6.0) |
|
|
18
|
+
| `BannerAdCompose` | Banner ad with lifecycle management |
|
|
19
|
+
| `NativeBannerSmallCompose` | Small native banner (80dp) |
|
|
20
|
+
| `NativeBannerMediumCompose` | Medium native banner (120dp) |
|
|
21
|
+
| `NativeLargeCompose` | Large native ad (300dp) |
|
|
22
|
+
| `ProgrammaticNativeAdCompose` | Programmatic native ad loading |
|
|
23
|
+
| `rememberInterstitialAd` | Interstitial ad with preloading |
|
|
24
|
+
| `rememberInterstitialAdState` | Advanced interstitial state management |
|
|
25
|
+
| `ConditionalAd` | Show ads only for non-purchased users |
|
|
26
|
+
| `CacheWarmingEffect` | Pre-load ads for better performance |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## NativeTemplateCompose (NEW in 2.6.0)
|
|
31
|
+
|
|
32
|
+
A Compose wrapper for `NativeTemplateView` supporting all 28 template styles.
|
|
33
|
+
|
|
34
|
+
### Basic Usage
|
|
35
|
+
|
|
36
|
+
```kotlin
|
|
37
|
+
@Composable
|
|
38
|
+
fun MyScreen() {
|
|
39
|
+
NativeTemplateCompose(
|
|
40
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
41
|
+
template = NativeAdTemplate.CARD_MODERN,
|
|
42
|
+
onAdLoaded = { println("Ad loaded") },
|
|
43
|
+
onAdFailedToLoad = { error -> println("Failed: ${error?.message}") }
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### With Loading Strategy
|
|
49
|
+
|
|
50
|
+
```kotlin
|
|
51
|
+
@Composable
|
|
52
|
+
fun MyScreen() {
|
|
53
|
+
NativeTemplateCompose(
|
|
54
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
55
|
+
template = NativeAdTemplate.MATERIAL3,
|
|
56
|
+
loadingStrategy = AdLoadingStrategy.HYBRID, // or ONLY_CACHE, ON_DEMAND
|
|
57
|
+
onAdLoaded = { /* success */ }
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Available Templates
|
|
63
|
+
|
|
64
|
+
```kotlin
|
|
65
|
+
// Standard Templates
|
|
66
|
+
NativeAdTemplate.CARD_MODERN // General purpose
|
|
67
|
+
NativeAdTemplate.MATERIAL3 // Material Design 3
|
|
68
|
+
NativeAdTemplate.MINIMAL // Clean, minimal
|
|
69
|
+
NativeAdTemplate.COMPACT_HORIZONTAL // Horizontal layout
|
|
70
|
+
NativeAdTemplate.STORY_STYLE // Social/story style
|
|
71
|
+
NativeAdTemplate.FULL_WIDTH_BANNER // Full width
|
|
72
|
+
NativeAdTemplate.GRID_CARD // Grid layouts
|
|
73
|
+
NativeAdTemplate.LIST_ITEM // List/RecyclerView items
|
|
74
|
+
NativeAdTemplate.FEATURED // Hero sections
|
|
75
|
+
NativeAdTemplate.OVERLAY_DARK // Dark overlay on media
|
|
76
|
+
NativeAdTemplate.MAGAZINE // News/blog style
|
|
77
|
+
NativeAdTemplate.MEDIA_CONTENT_SPLIT // Media/content split
|
|
78
|
+
NativeAdTemplate.APP_STORE // Store listing style
|
|
79
|
+
NativeAdTemplate.SOCIAL_FEED // Sponsored feed layout
|
|
80
|
+
NativeAdTemplate.GRADIENT_CARD // Gradient overlay hero
|
|
81
|
+
NativeAdTemplate.PILL_BANNER // Pill-shaped banner
|
|
82
|
+
NativeAdTemplate.MEDIUM_HORIZONTAL // 55/45 media-content split
|
|
83
|
+
NativeAdTemplate.SPOTLIGHT // Centered hero with large icon
|
|
84
|
+
NativeAdTemplate.FLEXIBLE // Adaptive media-focused layout
|
|
85
|
+
NativeAdTemplate.GRID_ITEM // Compact grid item
|
|
86
|
+
NativeAdTemplate.TOP_ICON_MEDIA // Top icon, media center
|
|
87
|
+
NativeAdTemplate.ICON_LEFT // Left icon column layout
|
|
88
|
+
|
|
89
|
+
// Video Templates
|
|
90
|
+
NativeAdTemplate.VIDEO_SMALL // 120x120dp
|
|
91
|
+
NativeAdTemplate.VIDEO_MEDIUM // 180dp height
|
|
92
|
+
NativeAdTemplate.VIDEO_LARGE // 250dp height
|
|
93
|
+
NativeAdTemplate.VIDEO_SQUARE // 300x300dp
|
|
94
|
+
NativeAdTemplate.VIDEO_VERTICAL // 9:16 ratio
|
|
95
|
+
NativeAdTemplate.VIDEO_FULLSCREEN // Fullscreen
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Convenience Functions
|
|
99
|
+
|
|
100
|
+
```kotlin
|
|
101
|
+
// Use specific templates directly
|
|
102
|
+
NativeCardModernCompose(adUnitId = adUnitId)
|
|
103
|
+
NativeMaterial3Compose(adUnitId = adUnitId)
|
|
104
|
+
NativeMinimalCompose(adUnitId = adUnitId)
|
|
105
|
+
NativeCompactHorizontalCompose(adUnitId = adUnitId)
|
|
106
|
+
NativeListItemCompose(adUnitId = adUnitId)
|
|
107
|
+
NativeMagazineCompose(adUnitId = adUnitId)
|
|
108
|
+
NativeFeaturedCompose(adUnitId = adUnitId)
|
|
109
|
+
NativeVideoMediumCompose(adUnitId = adUnitId)
|
|
110
|
+
NativeVideoLargeCompose(adUnitId = adUnitId)
|
|
111
|
+
NativeVideoSquareCompose(adUnitId = adUnitId)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Loading Strategies (NEW in 2.6.0)
|
|
117
|
+
|
|
118
|
+
Native ad Compose components support `loadingStrategy` parameter with `ON_DEMAND` and `HYBRID`:
|
|
119
|
+
|
|
120
|
+
> **Note:** `ONLY_CACHE` is only available for Interstitial and App Open ads, not for native ads.
|
|
121
|
+
|
|
122
|
+
```kotlin
|
|
123
|
+
// ON_DEMAND - Always fetch fresh ad
|
|
124
|
+
NativeBannerMediumCompose(
|
|
125
|
+
adUnitId = adUnitId,
|
|
126
|
+
loadingStrategy = AdLoadingStrategy.ON_DEMAND
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
// HYBRID - Check cache first, fetch if needed (recommended)
|
|
130
|
+
NativeBannerMediumCompose(
|
|
131
|
+
adUnitId = adUnitId,
|
|
132
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Banner Ads
|
|
139
|
+
|
|
140
|
+
```kotlin
|
|
141
|
+
@Composable
|
|
142
|
+
fun BannerExample() {
|
|
143
|
+
Column {
|
|
144
|
+
Text("My App Content")
|
|
145
|
+
|
|
146
|
+
BannerAdCompose(
|
|
147
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
148
|
+
onAdLoaded = { println("Banner loaded") },
|
|
149
|
+
onAdFailedToLoad = { error -> println("Failed: ${error?.message}") }
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Native Ads (Traditional Sizes)
|
|
158
|
+
|
|
159
|
+
```kotlin
|
|
160
|
+
@Composable
|
|
161
|
+
fun NativeAdExamples() {
|
|
162
|
+
LazyColumn {
|
|
163
|
+
item {
|
|
164
|
+
// Small (80dp height)
|
|
165
|
+
NativeBannerSmallCompose(
|
|
166
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
167
|
+
loadingStrategy = AdLoadingStrategy.ONLY_CACHE
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
item {
|
|
172
|
+
// Medium (120dp height)
|
|
173
|
+
NativeBannerMediumCompose(
|
|
174
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
175
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
item {
|
|
180
|
+
// Large (300dp height)
|
|
181
|
+
NativeLargeCompose(
|
|
182
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
183
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Generic NativeAdCompose
|
|
191
|
+
|
|
192
|
+
```kotlin
|
|
193
|
+
@Composable
|
|
194
|
+
fun GenericNativeAd() {
|
|
195
|
+
NativeAdCompose(
|
|
196
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
197
|
+
size = NativeAdSize.MEDIUM, // SMALL, MEDIUM, or LARGE
|
|
198
|
+
loadingStrategy = AdLoadingStrategy.HYBRID,
|
|
199
|
+
onAdLoaded = { /* success */ },
|
|
200
|
+
onAdFailedToLoad = { error -> /* handle error */ },
|
|
201
|
+
onAdClicked = { /* track click */ },
|
|
202
|
+
onAdImpression = { /* track impression */ },
|
|
203
|
+
onPaidEvent = { adValue -> /* track revenue */ }
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Interstitial Ads
|
|
211
|
+
|
|
212
|
+
### Simple Usage
|
|
213
|
+
|
|
214
|
+
```kotlin
|
|
215
|
+
@Composable
|
|
216
|
+
fun InterstitialExample() {
|
|
217
|
+
val showInterstitial = rememberInterstitialAd(
|
|
218
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
219
|
+
preloadAd = true,
|
|
220
|
+
onAdShown = { println("Ad shown") },
|
|
221
|
+
onAdDismissed = { println("Ad dismissed") }
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
Button(onClick = { showInterstitial() }) {
|
|
225
|
+
Text("Show Interstitial")
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Advanced State Management
|
|
231
|
+
|
|
232
|
+
```kotlin
|
|
233
|
+
@Composable
|
|
234
|
+
fun AdvancedInterstitialExample() {
|
|
235
|
+
val interstitialState = rememberInterstitialAdState(
|
|
236
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
237
|
+
autoLoad = true
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
Column {
|
|
241
|
+
Text("Ad Status: ${if (interstitialState.isLoaded) "Ready" else "Loading"}")
|
|
242
|
+
|
|
243
|
+
// Time-based display
|
|
244
|
+
Button(
|
|
245
|
+
onClick = { interstitialState.showAdByTime() },
|
|
246
|
+
enabled = interstitialState.isLoaded
|
|
247
|
+
) {
|
|
248
|
+
Text("Show (Time-based)")
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Count-based display
|
|
252
|
+
Button(
|
|
253
|
+
onClick = { interstitialState.showAdByCount(maxCount = 3) },
|
|
254
|
+
enabled = interstitialState.isLoaded
|
|
255
|
+
) {
|
|
256
|
+
Text("Show (Count-based)")
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Force show
|
|
260
|
+
Button(
|
|
261
|
+
onClick = { interstitialState.forceShowAd() },
|
|
262
|
+
enabled = interstitialState.isLoaded
|
|
263
|
+
) {
|
|
264
|
+
Text("Force Show")
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Force show with dialog
|
|
268
|
+
Button(onClick = { interstitialState.forceShowAdWithDialog() }) {
|
|
269
|
+
Text("Show with Dialog")
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Error display
|
|
273
|
+
interstitialState.lastError?.let { error ->
|
|
274
|
+
Text("Error: $error", color = Color.Red)
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Declarative Effect
|
|
281
|
+
|
|
282
|
+
```kotlin
|
|
283
|
+
@Composable
|
|
284
|
+
fun InterstitialEffectExample() {
|
|
285
|
+
InterstitialAdEffect(
|
|
286
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
287
|
+
showMode = InterstitialShowMode.TIME, // TIME, COUNT, FORCE, FORCE_WITH_DIALOG
|
|
288
|
+
maxDisplayCount = 3,
|
|
289
|
+
onAdShown = { /* shown */ },
|
|
290
|
+
onAdDismissed = { /* dismissed */ }
|
|
291
|
+
)
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Conditional Ads
|
|
298
|
+
|
|
299
|
+
Show ads only for users who haven't purchased:
|
|
300
|
+
|
|
301
|
+
```kotlin
|
|
302
|
+
@Composable
|
|
303
|
+
fun ConditionalAdExample() {
|
|
304
|
+
Column {
|
|
305
|
+
Text("App Content")
|
|
306
|
+
|
|
307
|
+
// Only shows if user hasn't purchased
|
|
308
|
+
ConditionalAd {
|
|
309
|
+
NativeTemplateCompose(
|
|
310
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
311
|
+
template = NativeAdTemplate.CARD_MODERN
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
Text("More Content")
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Cache Warming
|
|
323
|
+
|
|
324
|
+
Pre-load ads for better performance:
|
|
325
|
+
|
|
326
|
+
```kotlin
|
|
327
|
+
@Composable
|
|
328
|
+
fun CacheWarmingExample() {
|
|
329
|
+
// Warm cache when composable enters composition
|
|
330
|
+
CacheWarmingEffect(
|
|
331
|
+
adUnits = mapOf(
|
|
332
|
+
"ca-app-pub-xxx/native1" to 2, // Preload 2 ads
|
|
333
|
+
"ca-app-pub-xxx/native2" to 1 // Preload 1 ad
|
|
334
|
+
),
|
|
335
|
+
onComplete = { warmedUnits, totalUnits ->
|
|
336
|
+
println("Warmed $warmedUnits of $totalUnits ad units")
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
// Your content
|
|
341
|
+
MyAppContent()
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Monitoring & Statistics
|
|
348
|
+
|
|
349
|
+
```kotlin
|
|
350
|
+
@Composable
|
|
351
|
+
fun MonitoringExample() {
|
|
352
|
+
// Monitor purchase status
|
|
353
|
+
val isPurchased = rememberPurchaseStatus()
|
|
354
|
+
|
|
355
|
+
// Monitor cache statistics
|
|
356
|
+
val cacheStats by rememberCacheStatistics()
|
|
357
|
+
|
|
358
|
+
// Monitor performance
|
|
359
|
+
val perfStats by rememberPerformanceStats()
|
|
360
|
+
|
|
361
|
+
Column {
|
|
362
|
+
Text("Purchased: $isPurchased")
|
|
363
|
+
Text("Cache Hit Rate: ${perfStats["hit_rate_percent"]}%")
|
|
364
|
+
Text("Total Ads Served: ${perfStats["total_ads_served"]}")
|
|
365
|
+
|
|
366
|
+
cacheStats.forEach { (adUnit, stats) ->
|
|
367
|
+
Text("$adUnit: $stats")
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Initialization
|
|
376
|
+
|
|
377
|
+
Initialize AdManageKit in your Compose app:
|
|
378
|
+
|
|
379
|
+
```kotlin
|
|
380
|
+
@Composable
|
|
381
|
+
fun MyApp() {
|
|
382
|
+
// Initialize with Firebase Analytics
|
|
383
|
+
AdManageKitInitEffect()
|
|
384
|
+
|
|
385
|
+
// Your app content
|
|
386
|
+
MyAppContent()
|
|
387
|
+
}
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Complete Example
|
|
393
|
+
|
|
394
|
+
```kotlin
|
|
395
|
+
@Composable
|
|
396
|
+
fun AdDemoScreen() {
|
|
397
|
+
// Initialize
|
|
398
|
+
AdManageKitInitEffect()
|
|
399
|
+
|
|
400
|
+
// Warm cache
|
|
401
|
+
CacheWarmingEffect(
|
|
402
|
+
adUnits = mapOf("ca-app-pub-xxx/yyy" to 2)
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
val isPurchased = rememberPurchaseStatus()
|
|
406
|
+
|
|
407
|
+
LazyColumn {
|
|
408
|
+
item {
|
|
409
|
+
Text("Welcome to My App", style = MaterialTheme.typography.headlineMedium)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Only show ads if not purchased
|
|
413
|
+
if (!isPurchased) {
|
|
414
|
+
item {
|
|
415
|
+
// Use NativeTemplateView with Material 3 style
|
|
416
|
+
NativeTemplateCompose(
|
|
417
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
418
|
+
template = NativeAdTemplate.MATERIAL3,
|
|
419
|
+
loadingStrategy = AdLoadingStrategy.HYBRID,
|
|
420
|
+
modifier = Modifier.padding(16.dp)
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
items(10) { index ->
|
|
426
|
+
Text("Content Item $index")
|
|
427
|
+
|
|
428
|
+
// Show ad every 5 items
|
|
429
|
+
if (index % 5 == 4 && !isPurchased) {
|
|
430
|
+
NativeListItemCompose(
|
|
431
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
432
|
+
loadingStrategy = AdLoadingStrategy.ONLY_CACHE
|
|
433
|
+
)
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
item {
|
|
438
|
+
// Video ad at the end
|
|
439
|
+
NativeVideoMediumCompose(
|
|
440
|
+
adUnitId = "ca-app-pub-xxx/yyy",
|
|
441
|
+
loadingStrategy = AdLoadingStrategy.HYBRID
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## Migration from Views to Compose
|
|
451
|
+
|
|
452
|
+
```kotlin
|
|
453
|
+
// View system
|
|
454
|
+
val nativeTemplateView = NativeTemplateView(context)
|
|
455
|
+
nativeTemplateView.setTemplate(NativeAdTemplate.MATERIAL3)
|
|
456
|
+
nativeTemplateView.loadNativeAd(activity, adUnitId)
|
|
457
|
+
|
|
458
|
+
// Compose equivalent
|
|
459
|
+
@Composable
|
|
460
|
+
fun MyScreen() {
|
|
461
|
+
NativeTemplateCompose(
|
|
462
|
+
adUnitId = adUnitId,
|
|
463
|
+
template = NativeAdTemplate.MATERIAL3
|
|
464
|
+
)
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Best Practices
|
|
471
|
+
|
|
472
|
+
1. **Use `ONLY_CACHE` in LazyColumn/LazyRow** for smooth scrolling
|
|
473
|
+
2. **Use `HYBRID` for static placements** for balance between coverage and UX
|
|
474
|
+
3. **Enable cache warming** at app start for better ad availability
|
|
475
|
+
4. **Use `ConditionalAd`** to respect user purchases
|
|
476
|
+
5. **Handle callbacks** for analytics and error tracking
|
|
477
|
+
6. **Choose appropriate templates** for your layout context
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# AdManageKitConfig Usage Guide
|
|
2
|
+
|
|
3
|
+
This guide shows how to use the new `AdManageKitConfig` in your ad implementations.
|
|
4
|
+
|
|
5
|
+
## Basic Configuration
|
|
6
|
+
|
|
7
|
+
Configure AdManageKit in your Application class:
|
|
8
|
+
|
|
9
|
+
```kotlin
|
|
10
|
+
class MyApp : Application() {
|
|
11
|
+
override fun onCreate() {
|
|
12
|
+
super.onCreate()
|
|
13
|
+
|
|
14
|
+
// Configure AdManageKit
|
|
15
|
+
AdManageKitConfig.apply {
|
|
16
|
+
debugMode = BuildConfig.DEBUG
|
|
17
|
+
enableSmartPreloading = true
|
|
18
|
+
autoRetryFailedAds = true
|
|
19
|
+
maxRetryAttempts = 3
|
|
20
|
+
enablePerformanceMetrics = true
|
|
21
|
+
defaultBannerRefreshInterval = 60.seconds
|
|
22
|
+
enableCollapsibleBannersByDefault = false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Set up billing
|
|
26
|
+
BillingConfig.setPurchaseProvider(BillingPurchaseProvider())
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Advanced Configuration
|
|
32
|
+
|
|
33
|
+
```kotlin
|
|
34
|
+
AdManageKitConfig.apply {
|
|
35
|
+
// Performance settings
|
|
36
|
+
defaultAdTimeout = 15.seconds
|
|
37
|
+
nativeCacheExpiry = 2.hours
|
|
38
|
+
maxCachedAdsPerUnit = 5
|
|
39
|
+
|
|
40
|
+
// Reliability features
|
|
41
|
+
autoRetryFailedAds = true
|
|
42
|
+
maxRetryAttempts = 3
|
|
43
|
+
circuitBreakerThreshold = 5
|
|
44
|
+
enableExponentialBackoff = true
|
|
45
|
+
baseRetryDelay = 1.seconds
|
|
46
|
+
maxRetryDelay = 30.seconds
|
|
47
|
+
|
|
48
|
+
// Advanced features
|
|
49
|
+
enableSmartPreloading = true
|
|
50
|
+
enableAdaptiveIntervals = true
|
|
51
|
+
enablePerformanceMetrics = true
|
|
52
|
+
enableAutoCacheCleanup = true
|
|
53
|
+
|
|
54
|
+
// Debug and testing
|
|
55
|
+
debugMode = BuildConfig.DEBUG
|
|
56
|
+
testMode = false
|
|
57
|
+
privacyCompliantMode = true
|
|
58
|
+
enableDebugOverlay = false
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## How Configuration Affects Ads
|
|
63
|
+
|
|
64
|
+
### Banner Ads
|
|
65
|
+
- `autoRetryFailedAds` and `maxRetryAttempts` control retry behavior
|
|
66
|
+
- `enableExponentialBackoff` affects retry delays
|
|
67
|
+
- `defaultBannerRefreshInterval` sets auto-refresh interval
|
|
68
|
+
- `enableCollapsibleBannersByDefault` enables collapsible banners globally
|
|
69
|
+
- `enablePerformanceMetrics` adds detailed analytics
|
|
70
|
+
|
|
71
|
+
### Native Ads
|
|
72
|
+
- `enableSmartPreloading` enables intelligent caching
|
|
73
|
+
- `maxCachedAdsPerUnit` limits cache size per ad unit
|
|
74
|
+
- `nativeCacheExpiry` sets cache expiration time
|
|
75
|
+
- `enableAutoCacheCleanup` enables automatic cleanup
|
|
76
|
+
|
|
77
|
+
### Debug Features
|
|
78
|
+
- `debugMode` enables enhanced logging
|
|
79
|
+
- `testMode` enables test ad units
|
|
80
|
+
- `enableDebugOverlay` shows real-time debug info
|
|
81
|
+
- `enablePerformanceMetrics` logs performance data
|
|
82
|
+
|
|
83
|
+
## Example Usage in Activities
|
|
84
|
+
|
|
85
|
+
```kotlin
|
|
86
|
+
class MainActivity : AppCompatActivity() {
|
|
87
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
88
|
+
super.onCreate(savedInstanceState)
|
|
89
|
+
setContentView(R.layout.activity_main)
|
|
90
|
+
|
|
91
|
+
// Debug overlay (only in debug mode)
|
|
92
|
+
if (AdManageKitConfig.debugMode) {
|
|
93
|
+
AdDebugUtils.enableDebugOverlay(this, true)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Banner ad with configuration-based settings
|
|
97
|
+
val bannerAdView = findViewById<BannerAdView>(R.id.bannerAdView)
|
|
98
|
+
bannerAdView.loadBanner(this, "your-ad-unit-id")
|
|
99
|
+
|
|
100
|
+
// Auto-refresh is now configurable
|
|
101
|
+
if (AdManageKitConfig.defaultBannerRefreshInterval.inWholeSeconds >= 30) {
|
|
102
|
+
bannerAdView.enableAutoRefresh()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Native ads with smart caching
|
|
106
|
+
val nativeAdSmall = findViewById<NativeBannerSmall>(R.id.nativeAdSmall)
|
|
107
|
+
nativeAdSmall.loadNativeBannerAd(
|
|
108
|
+
this,
|
|
109
|
+
"your-native-ad-unit-id",
|
|
110
|
+
useCachedAd = AdManageKitConfig.enableSmartPreloading
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Production vs Debug Configuration
|
|
117
|
+
|
|
118
|
+
### Debug Configuration
|
|
119
|
+
```kotlin
|
|
120
|
+
AdManageKitConfig.apply {
|
|
121
|
+
debugMode = true
|
|
122
|
+
testMode = true // Use test ad units
|
|
123
|
+
enableDebugOverlay = true
|
|
124
|
+
enablePerformanceMetrics = true
|
|
125
|
+
maxRetryAttempts = 1 // Fail fast for testing
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Production Configuration
|
|
130
|
+
```kotlin
|
|
131
|
+
AdManageKitConfig.apply {
|
|
132
|
+
debugMode = false
|
|
133
|
+
testMode = false
|
|
134
|
+
enableDebugOverlay = false
|
|
135
|
+
privacyCompliantMode = true
|
|
136
|
+
enablePerformanceMetrics = false // Reduce overhead
|
|
137
|
+
maxRetryAttempts = 3
|
|
138
|
+
autoRetryFailedAds = true
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Configuration Validation
|
|
143
|
+
|
|
144
|
+
Always validate your configuration:
|
|
145
|
+
|
|
146
|
+
```kotlin
|
|
147
|
+
if (!AdManageKitConfig.validate()) {
|
|
148
|
+
Log.w("MyApp", "Invalid AdManageKit configuration detected")
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!AdManageKitConfig.isProductionReady()) {
|
|
152
|
+
Log.w("MyApp", "AdManageKit configuration not ready for production")
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Print configuration summary
|
|
156
|
+
Log.d("MyApp", AdManageKitConfig.getConfigSummary())
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Benefits of Using AdManageKitConfig
|
|
160
|
+
|
|
161
|
+
1. **Centralized Configuration**: Single point to control all ad behavior
|
|
162
|
+
2. **Environment-Specific Settings**: Easy debug vs production configuration
|
|
163
|
+
3. **Performance Optimization**: Fine-tune caching, retries, and timeouts
|
|
164
|
+
4. **Debug Tools**: Enhanced logging and monitoring capabilities
|
|
165
|
+
5. **Reliability Features**: Circuit breaker, exponential backoff, smart retries
|
|
166
|
+
6. **Flexibility**: Runtime configuration changes without code modifications
|
|
167
|
+
|
|
168
|
+
The configuration automatically affects all ad components (BannerAdView, NativeBannerSmall, NativeBannerMedium, NativeLarge) and provides consistent behavior across your entire app.
|