KAdmob
### KAdmob is a Kotlin Multiplatform Mobile (KMM) library that enables seamless integration of Google AdMob advertisements in Android and iOS applications using a unified codebase. It provides a simplified interface for displaying banner ads, interstitial ads, and rewarded video ads across both platforms with minimal configuration
[![Maven Central](https://img.shields.io/maven-central/v/io.github.the-best-is-best/kadmob)](https://central.sonatype.com/artifact/io.github.the-best-is-best/kadmob)
KAdmob is available on `mavenCentral()`.
## Install
```kotlin
implementation("io.github.the-best-is-best:kadmob:1.0.1")
```
## Need add this in pod file if not exist run ` pod init `
```pod
pod 'KAdmob' , '0.1.2'
```
## How to use it
### First in iosApp
```swift
GADMobileAds.sharedInstance().start(completionHandler: nil)
```
### Second in androidMain
```kotlin
AndroidKAdmob.initialization(this)
```
### in commonMain
#### init unit ads id
```kotlin
val interstitialAd = KAdmobInterstitialAd()
interstitialAd.loadInterstitialAd("ca-app-pub-7284367511062855/1974850970")
val rewardAd = KAdmobRewardedAd()
rewardAd.loadRewardedAd("ca-app-pub-3940256099942544/1712485313")
val rewardedInterstitialAd = KAdmobRewardedInterstitialAd()
rewardedInterstitialAd.loadRewardedInterstitialAd("ca-app-pub-3940256099942544/6978759866")
```
#### show ad
```kotlin
ElevatedButton(onClick = {
interstitialAd.showInterstitialAd()
}) {
Text("InterstitialAd")
}
ElevatedButton(onClick = {
rewardAd.show(reloadAd) {
it.onSuccess {
println("reward is $it")
}
}
}) {
Text("rewardAd")
}
ElevatedButton(onClick = {
rewardedInterstitialAd.show(reloadAd) {
it.onSuccess {
println("rewardedInterstitialAd is $it")
}
}
}) {
Text("rewardedInterstitialAd")
}
KBannerAd(
modifier = Modifier
.fillMaxWidth()
.height(150.dp),
type = KAdmobBannerType.LARGE_BANNER,
adUnitId = "ca-app-pub-3940256099942544/6300978111" // Test ID
)
```