Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/sakebook/flutter_native_ads

Show AdMob Native Ads use PlatformView
https://github.com/sakebook/flutter_native_ads

admob android flutter flutter-plugin ios native-ads platform-view

Last synced: 20 days ago
JSON representation

Show AdMob Native Ads use PlatformView

Awesome Lists containing this project

README

        

# flutter_native_ads
[![version](https://img.shields.io/pub/v/native_ads.svg?style=flat-square)](https://pub.dartlang.org/packages/native_ads)

Flutter plugin for AdMob Native Ads. Compatible with Android and iOS using PlatformView.

|Android|iOS|
|:---:|:---:|
|![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_capture.png)|![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/ios_capture.png)|

## Getting Started
### Android
- [AndroidManifest changes](https://developers.google.com/admob/android/quick-start#update_your_androidmanifestxml)

AdMob 17 requires the App ID to be included in the `AndroidManifest.xml`. Failure
to do so will result in a crash on launch of your app. The line should look like:

```xml

```

where `[ADMOB_APP_ID]` is your App ID. You must pass the same value when you
initialize the plugin in your Dart code.

### iOS
- [Info.plist changes](https://developers.google.com/admob/ios/quick-start#update_your_infoplist)

Admob 7.42.0 requires the App ID to be included in `Info.plist`. Failure to do so will result in a crash on launch of your app. The lines should look like:

```xml
GADApplicationIdentifier
[ADMOB_APP_ID]
```

where `[ADMOB_APP_ID]` is your App ID. You must pass the same value when you initialize the plugin in your Dart code.

And PlatformView

```xml
io.flutter.embedded_views_preview

```

## Layout
This plugin supported custom layout. You need to create a layout file.

### Android
You can use anything if the parent is a ViewGroup.
The example uses ConstraintLayout.

Use [`com.google.android.gms.ads.formats.UnifiedNativeAdView`](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/UnifiedNativeAdView) for the parent.

![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_unified_native_ad_view.png)

Use [`com.google.android.gms.ads.formats.MediaView`](https://developers.google.com/android/reference/com/google/android/gms/ads/formats/MediaView) for MediaView.

![image](https://raw.githubusercontent.com/sakebook/flutter_native_ads/master/art/android_media_view.png)

- xml

```xml



...

print("onAdImpression!!!"),
onAdClicked: () => print("onAdClicked!!!"),
onAdFailedToLoad: (Map error) => print("onAdFailedToLoad!!! $error"),
),
),
);
} else {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"this is text $index",
style: Theme.of(context).textTheme.body1,
),
);
}
},
itemCount: 50,
separatorBuilder: (context, _) => const Divider(),
),
),
),
);
}
}
```

## Supported native ads fields
- Headline(Required)
- Body(Required)
- Call To Action(Required)
- Ad Attribution(Required)
- Media
- Icon
- Star rating
- Store
- Price
- Advertiser

## Event callback
Receive callbacks for some events by passing to the NativeAdView constructor

- onAdImpression
- onAdClicked
- onAdFailedToLoad
- onAdLeftApplication
- onAdLoaded

## Reference
- Mobile Ads SDK Release Notes
- [Android](https://developers.google.com/admob/android/rel-notes)
- [iOS](https://developers.google.com/admob/ios/rel-notes)

## Limitations

This is just an initial version of the plugin. There are still some
limitations:

- No support [Mediation Ads](https://developers.google.com/admob/android/mediate).