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
- Host: GitHub
- URL: https://github.com/farimarwat/admob_nativeads_compose
- Owner: farimarwat
- Created: 2023-06-01T07:22:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-05T07:07:40.000Z (over 1 year ago)
- Last Synced: 2025-02-05T08:21:47.593Z (over 1 year ago)
- Topics: admob, android, compose, jetpack-compose, nativeads
- Language: Kotlin
- Homepage:
- Size: 354 KB
- Stars: 35
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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
)
```