An open API service indexing awesome lists of open source software.

https://github.com/farimarwat/admob_nativeads_compose

Admob NativeAds JetPack Compose Library
https://github.com/farimarwat/admob_nativeads_compose

admob android compose jetpack-compose nativeads

Last synced: 5 months ago
JSON representation

Admob NativeAds JetPack Compose Library

Awesome Lists containing this project

README

          

# AdMob Native Compose

A simple way to implement native ads in your Jetpack Compose Android project.

## Setup

Add the dependency in your app level `build.gradle`:

```gradle
dependencies {
implementation 'io.github.farimarwat:admobnative-compose:1.4'
implementation 'com.google.android.gms:play-services-ads:22.6.0' // Required dependency
}
```

## Usage

### Basic Implementation

Add the below in `Manifest`

```

```

The very basic example:
```kotlin
val adState = rememberNativeAdState(
context = LocalContext.current,
adUnitId = "your_ad_unit_id",
refreshInterval = 60000L
)

BannerAdAdmobSmall(
context = LocalContext.current,
loadedAd = adState
)
```

Only two types of banners available:

```
BannerAdAdmobSmall()

BannerAdAdmobMedium()
```

### Custom Colors

```kotlin
val customColors = AdColors(
headlineText = Color.White,
bodyText = Color.Gray,
buttonText = Color.Black,
badgeText = Color.White
)

BannerAdAdmobSmall(
context = LocalContext.current,
loadedAd = adState,
adColors = customColors
)
```

### With Error Handling

```kotlin
val adState = rememberNativeAdState(
context = LocalContext.current,
adUnitId = "your_ad_unit_id",
refreshInterval = 60000L,
onAdLoaded = {
// Handle successful ad load
},
onAdFailedToLoad = { error ->
// Handle ad load failure
}
)
```

### Custom Backgrounds

```kotlin
BannerAdAdmobSmall(
context = LocalContext.current,
loadedAd = adState,
adBackground = yourCustomDrawable,
actionButtonBackground = yourButtonDrawable,
badgeBackground = yourBadgeDrawable
)
```